mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
push app/route cache down to datastore (#303)
cache now implements models.Datastore by just embedding one and then changing GetApp and GetRoute to have the cache inside. this makes it really flexible for things like testing, so now the agent doesn't automagically do caching, now it must be passed a datastore that was wrapped with a cache datastore. the datastore in the server can remain separate and not use the cache still, and then now the agent when running fn 'for real' is configured with the cache baked in. this seems a lot cleaner than what we had and gets the cache out of the way and it's easier to swap in / out / extend.
This commit is contained in:
committed by
Travis Reeder
parent
3d8ca450bb
commit
59d95d660a
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/fnproject/fn/api/agent"
|
||||
"github.com/fnproject/fn/api/common"
|
||||
"github.com/fnproject/fn/api/datastore"
|
||||
"github.com/fnproject/fn/api/datastore/cache"
|
||||
"github.com/fnproject/fn/api/id"
|
||||
"github.com/fnproject/fn/api/logs"
|
||||
"github.com/fnproject/fn/api/models"
|
||||
@@ -74,7 +75,7 @@ func NewFromEnv(ctx context.Context) *Server {
|
||||
// New creates a new Functions server with the passed in datastore, message queue and API URL
|
||||
func New(ctx context.Context, ds models.Datastore, mq models.MessageQueue, logDB models.LogStore, opts ...ServerOption) *Server {
|
||||
s := &Server{
|
||||
Agent: agent.New(ds, mq),
|
||||
Agent: agent.New(cache.Wrap(ds), mq), // only add datastore caching to agent
|
||||
Router: gin.New(),
|
||||
Datastore: ds,
|
||||
MQ: mq,
|
||||
|
||||
Reference in New Issue
Block a user