mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-27 22:41:10 -05:00
settings: Instanciate only a single instance of the ServiceHandler/Store
Share the same instance between the HTTP and the GRPC service. This is in preparation for moving the cache of the metadata storage backend to a go-micro/store based implementation. By sharing the same service instance in the HTTP and GRPC services we can avoid the usage of global variables for the caches, which will make the move to the go-micro/store implementation simpler.
This commit is contained in:
committed by
Ralf Haferkamp
parent
3e92e409f7
commit
18bb3dbaca
@@ -11,10 +11,6 @@ import (
|
||||
|
||||
var (
|
||||
cachettl = 0
|
||||
// these need to be global instances for now as the `Service` (and therefore the `Store`) are instantiated twice (for grpc and http)
|
||||
// therefore caches need to cover both instances
|
||||
dircache = initCache(cachettl)
|
||||
filescache = initCache(cachettl)
|
||||
)
|
||||
|
||||
// CachedMDC is cache for the metadataclient
|
||||
@@ -99,8 +95,8 @@ func (c *CachedMDC) MakeDirIfNotExist(ctx context.Context, id string) error {
|
||||
|
||||
// Init instantiates the caches
|
||||
func (c *CachedMDC) Init(ctx context.Context, id string) error {
|
||||
c.dirs = dircache
|
||||
c.files = filescache
|
||||
c.dirs = initCache(cachettl)
|
||||
c.files = initCache(cachettl)
|
||||
return c.next.Init(ctx, id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user