bump reva

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-12-14 16:50:09 +01:00
parent 423c28b298
commit db2c311d59
23 changed files with 121 additions and 131 deletions
+1
View File
@@ -4,3 +4,4 @@ Bumps reva version
https://github.com/owncloud/ocis/pull/7793
https://github.com/owncloud/ocis/pull/7978
https://github.com/owncloud/ocis/pull/7979
+1 -1
View File
@@ -13,7 +13,7 @@ require (
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.9.0
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781
github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f
github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/disintegration/imaging v1.6.2
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
+2 -4
View File
@@ -1021,8 +1021,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY=
github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f h1:AF7fcQ7dfi3sxKLpIFJ8Y2uKJ8umB9K+nFe+3tDa4oA=
github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U=
github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47 h1:6DfMeFpCXoqlfm/+FJ/mFs8Ul5WCZNlorsbDM9Z/ATE=
github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -1688,8 +1688,6 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD
github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus=
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY=
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE=
github.com/micbar/reva/v2 v2.0.0-20231214215940-ac484c63b45e h1:IsCx3d+WflZgIGFV5TPqGoMRWiygaj11QJvefcUNTUQ=
github.com/micbar/reva/v2 v2.0.0-20231214215940-ac484c63b45e/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
+25 -40
View File
@@ -22,7 +22,6 @@ import (
"fmt"
"net/url"
"strings"
"time"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
"github.com/cs3org/reva/v2/pkg/errtypes"
@@ -64,26 +63,14 @@ type config struct {
TokenManager string `mapstructure:"token_manager"`
// ShareFolder is the location where to create shares in the recipient's storage provider.
// FIXME get rid of ShareFolder, there are findByPath calls in the ocmshareporvider.go and usershareprovider.go
ShareFolder string `mapstructure:"share_folder"`
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"`
AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent
StatCacheStore string `mapstructure:"stat_cache_store"`
StatCacheNodes []string `mapstructure:"stat_cache_nodes"`
StatCacheDatabase string `mapstructure:"stat_cache_database"`
StatCacheTTL int `mapstructure:"stat_cache_ttl"`
StatCacheSize int `mapstructure:"stat_cache_size"`
CreateHomeCacheStore string `mapstructure:"create_home_cache_store"`
CreateHomeCacheNodes []string `mapstructure:"create_home_cache_nodes"`
CreateHomeCacheDatabase string `mapstructure:"create_home_cache_database"`
CreateHomeCacheTTL int `mapstructure:"create_home_cache_ttl"`
CreateHomeCacheSize int `mapstructure:"create_home_cache_size"`
ProviderCacheStore string `mapstructure:"provider_cache_store"`
ProviderCacheNodes []string `mapstructure:"provider_cache_nodes"`
ProviderCacheDatabase string `mapstructure:"provider_cache_database"`
ProviderCacheTTL int `mapstructure:"provider_cache_ttl"`
ProviderCacheSize int `mapstructure:"provider_cache_size"`
UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"`
ShareFolder string `mapstructure:"share_folder"`
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"`
AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent
StatCacheConfig cache.Config `mapstructure:"stat_cache_config"`
CreatePersonalSpaceCacheConfig cache.Config `mapstructure:"create_personal_space_cache_config"`
ProviderCacheConfig cache.Config `mapstructure:"provider_cache_config"`
UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"`
}
// sets defaults
@@ -130,28 +117,28 @@ func (c *config) init() {
}
// caching needs to be explicitly enabled
if c.StatCacheStore == "" {
c.StatCacheStore = "noop"
if c.StatCacheConfig.Store == "" {
c.StatCacheConfig.Store = "noop"
}
if c.StatCacheDatabase == "" {
c.StatCacheDatabase = "reva"
if c.StatCacheConfig.Database == "" {
c.StatCacheConfig.Database = "reva"
}
if c.ProviderCacheStore == "" {
c.ProviderCacheStore = "noop"
if c.ProviderCacheConfig.Store == "" {
c.ProviderCacheConfig.Store = "noop"
}
if c.ProviderCacheDatabase == "" {
c.ProviderCacheDatabase = "reva"
if c.ProviderCacheConfig.Database == "" {
c.ProviderCacheConfig.Database = "reva"
}
if c.CreateHomeCacheStore == "" {
c.CreateHomeCacheStore = "noop"
if c.CreatePersonalSpaceCacheConfig.Store == "" {
c.CreatePersonalSpaceCacheConfig.Store = "noop"
}
if c.CreateHomeCacheDatabase == "" {
c.CreateHomeCacheDatabase = "reva"
if c.CreatePersonalSpaceCacheConfig.Database == "" {
c.CreatePersonalSpaceCacheConfig.Database = "reva"
}
}
@@ -161,14 +148,13 @@ type svc struct {
tokenmgr token.Manager
statCache cache.StatCache
providerCache cache.ProviderCache
createHomeCache cache.CreateHomeCache
createPersonalSpaceCache cache.CreatePersonalSpaceCache
}
// New creates a new gateway svc that acts as a proxy for any grpc operation.
// The gateway is responsible for high-level controls: rate-limiting, coordination between svcs
// like sharing and storage acls, asynchronous transactions, ...
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, _ *grpc.Server) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
@@ -191,10 +177,9 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
c: c,
dataGatewayURL: *u,
tokenmgr: tokenManager,
statCache: cache.GetStatCache(c.StatCacheStore, c.StatCacheNodes, c.StatCacheDatabase, "stat", time.Duration(c.StatCacheTTL)*time.Second, c.StatCacheSize),
providerCache: cache.GetProviderCache(c.ProviderCacheStore, c.ProviderCacheNodes, c.ProviderCacheDatabase, "provider", time.Duration(c.ProviderCacheTTL)*time.Second, c.ProviderCacheSize),
createHomeCache: cache.GetCreateHomeCache(c.CreateHomeCacheStore, c.CreateHomeCacheNodes, c.CreateHomeCacheDatabase, "createHome", time.Duration(c.CreateHomeCacheTTL)*time.Second, c.CreateHomeCacheSize),
createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreateHomeCacheStore, c.CreateHomeCacheNodes, c.CreateHomeCacheDatabase, "createPersonalSpace", time.Duration(c.CreateHomeCacheTTL)*time.Second, c.CreateHomeCacheSize),
statCache: cache.GetStatCache(c.StatCacheConfig),
providerCache: cache.GetProviderCache(c.ProviderCacheConfig),
createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreatePersonalSpaceCacheConfig),
}
return s, nil
@@ -207,7 +192,7 @@ func (s *svc) Register(ss *grpc.Server) {
func (s *svc) Close() error {
s.statCache.Close()
s.providerCache.Close()
s.createHomeCache.Close()
s.createPersonalSpaceCache.Close()
return nil
}
@@ -1107,7 +1107,6 @@ func (s *svc) getStorageProviderClient(_ context.Context, p *registry.ProviderIn
return &cachedAPIClient{
c: c,
statCache: s.statCache,
createHomeCache: s.createHomeCache,
createPersonalSpaceCache: s.createPersonalSpaceCache,
}, nil
}
@@ -85,7 +85,6 @@ func (c *cachedRegistryClient) GetHome(ctx context.Context, in *registry.GetHome
type cachedAPIClient struct {
c provider.ProviderAPIClient
statCache cache.StatCache
createHomeCache cache.CreateHomeCache
createPersonalSpaceCache cache.CreatePersonalSpaceCache
}
@@ -121,10 +120,10 @@ func (c *cachedAPIClient) Stat(ctx context.Context, in *provider.StatRequest, op
// CreateHome caches calls to CreateHome locally - anyways they only need to be called once per user
func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHomeRequest, opts ...grpc.CallOption) (*provider.CreateHomeResponse, error) {
key := c.createHomeCache.GetKey(ctxpkg.ContextMustGetUser(ctx).GetId())
key := c.createPersonalSpaceCache.GetKey(ctxpkg.ContextMustGetUser(ctx).GetId())
if key != "" {
s := &provider.CreateHomeResponse{}
if err := c.createHomeCache.PullFromCache(key, s); err == nil {
if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil {
return s, nil
}
}
@@ -137,7 +136,7 @@ func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHom
case key == "":
return resp, nil
default:
return resp, c.createHomeCache.PushToCache(key, resp)
return resp, c.createPersonalSpaceCache.PushToCache(key, resp)
}
}
@@ -21,6 +21,7 @@ package config
import (
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data"
"github.com/cs3org/reva/v2/pkg/sharedconf"
"github.com/cs3org/reva/v2/pkg/storage/cache"
)
// Config holds the config options that need to be passed down to all ocs handlers
@@ -37,12 +38,7 @@ type Config struct {
AdditionalInfoAttribute string `mapstructure:"additional_info_attribute"`
CacheWarmupDriver string `mapstructure:"cache_warmup_driver"`
CacheWarmupDrivers map[string]map[string]interface{} `mapstructure:"cache_warmup_drivers"`
StatCacheStore string `mapstructure:"stat_cache_store"`
StatCacheNodes []string `mapstructure:"stat_cache_nodes"`
StatCacheDatabase string `mapstructure:"stat_cache_database"`
StatCacheTable string `mapstructure:"stat_cache_table"`
StatCacheTTL int `mapstructure:"stat_cache_ttl"`
StatCacheSize int `mapstructure:"stat_cache_size"`
StatCacheConfig cache.Config `mapstructure:"stat_cache_config"`
UserIdentifierCacheTTL int `mapstructure:"user_identifier_cache_ttl"`
MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"`
SkipUpdatingExistingSharesMountpoints bool `mapstructure:"skip_updating_existing_shares_mountpoint"`
@@ -150,7 +150,7 @@ func (h *Handler) Init(c *config.Config) error {
h.publicPasswordEnforced = publicPwdEnforced(c)
h.passwordValidator = passwordPolicies(c)
h.statCache = cache.GetStatCache(c.StatCacheStore, c.StatCacheNodes, c.StatCacheDatabase, "stat", time.Duration(c.StatCacheTTL)*time.Second, c.StatCacheSize)
h.statCache = cache.GetStatCache(c.StatCacheConfig)
if c.CacheWarmupDriver != "" {
cwm, err := getCacheWarmupManager(c)
if err != nil {
@@ -20,7 +20,6 @@ package ocs
import (
"net/http"
"time"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees"
@@ -67,9 +66,9 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
return nil, err
}
if conf.CacheWarmupDriver == "first-request" && conf.StatCacheStore != "noop" {
if conf.CacheWarmupDriver == "first-request" && conf.StatCacheConfig.Store != "noop" {
s.warmupCacheTracker = ttlcache.NewCache()
_ = s.warmupCacheTracker.SetTTL(time.Second * time.Duration(conf.StatCacheTTL))
_ = s.warmupCacheTracker.SetTTL(conf.StatCacheConfig.TTL)
}
return s, nil
@@ -70,7 +70,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e
return &manager{
conf: c,
publisher: publisher,
statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size),
statCache: cache.GetStatCache(*c),
}, nil
}
@@ -72,7 +72,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e
return &manager{
conf: c,
publisher: publisher,
statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size),
statCache: cache.GetStatCache(*c),
}, nil
}
+1 -2
View File
@@ -23,7 +23,6 @@ import (
"log"
"net/http"
"path"
"time"
"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
@@ -71,7 +70,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e
return &manager{
conf: c,
publisher: publisher,
statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size),
statCache: cache.GetStatCache(*c),
}, nil
}
+30 -28
View File
@@ -44,12 +44,13 @@ var (
// Config contains the configuring for a cache
type Config struct {
Store string `mapstructure:"cache_store"`
Nodes []string `mapstructure:"cache_nodes"`
Database string `mapstructure:"cache_database"`
Table string `mapstructure:"cache_table"`
TTL int `mapstructure:"cache_ttl"`
Size int `mapstructure:"cache_size"`
Store string `mapstructure:"cache_store"`
Nodes []string `mapstructure:"cache_nodes"`
Database string `mapstructure:"cache_database"`
Table string `mapstructure:"cache_table"`
TTL time.Duration `mapstructure:"cache_ttl"`
Size int `mapstructure:"cache_size"`
DisablePersistence bool `mapstructure:"cache_disable_persistence"`
}
// Cache handles key value operations on caches
@@ -100,65 +101,65 @@ type FileMetadataCache interface {
// GetStatCache will return an existing StatCache for the given store, nodes, database and table
// If it does not exist yet it will be created, different TTLs are ignored
func GetStatCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) StatCache {
func GetStatCache(cfg Config) StatCache {
mutex.Lock()
defer mutex.Unlock()
key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":")
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
if statCaches[key] == nil {
statCaches[key] = NewStatCache(cacheStore, cacheNodes, database, table, ttl, size)
statCaches[key] = NewStatCache(cfg)
}
return statCaches[key]
}
// GetProviderCache will return an existing ProviderCache for the given store, nodes, database and table
// If it does not exist yet it will be created, different TTLs are ignored
func GetProviderCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) ProviderCache {
func GetProviderCache(cfg Config) ProviderCache {
mutex.Lock()
defer mutex.Unlock()
key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":")
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
if providerCaches[key] == nil {
providerCaches[key] = NewProviderCache(cacheStore, cacheNodes, database, table, ttl, size)
providerCaches[key] = NewProviderCache(cfg)
}
return providerCaches[key]
}
// GetCreateHomeCache will return an existing CreateHomeCache for the given store, nodes, database and table
// If it does not exist yet it will be created, different TTLs are ignored
func GetCreateHomeCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) CreateHomeCache {
func GetCreateHomeCache(cfg Config) CreateHomeCache {
mutex.Lock()
defer mutex.Unlock()
key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":")
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
if createHomeCaches[key] == nil {
createHomeCaches[key] = NewCreateHomeCache(cacheStore, cacheNodes, database, table, ttl, size)
createHomeCaches[key] = NewCreateHomeCache(cfg)
}
return createHomeCaches[key]
}
// GetCreatePersonalSpaceCache will return an existing CreatePersonalSpaceCache for the given store, nodes, database and table
// If it does not exist yet it will be created, different TTLs are ignored
func GetCreatePersonalSpaceCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) CreatePersonalSpaceCache {
func GetCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache {
mutex.Lock()
defer mutex.Unlock()
key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":")
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
if createPersonalSpaceCaches[key] == nil {
createPersonalSpaceCaches[key] = NewCreatePersonalSpaceCache(cacheStore, cacheNodes, database, table, ttl, size)
createPersonalSpaceCaches[key] = NewCreatePersonalSpaceCache(cfg)
}
return createPersonalSpaceCaches[key]
}
// GetFileMetadataCache will return an existing GetFileMetadataCache for the given store, nodes, database and table
// If it does not exist yet it will be created, different TTLs are ignored
func GetFileMetadataCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) FileMetadataCache {
func GetFileMetadataCache(cfg Config) FileMetadataCache {
mutex.Lock()
defer mutex.Unlock()
key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":")
key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":")
if fileMetadataCaches[key] == nil {
fileMetadataCaches[key] = NewFileMetadataCache(cacheStore, cacheNodes, database, table, ttl, size)
fileMetadataCaches[key] = NewFileMetadataCache(cfg)
}
return fileMetadataCaches[key]
}
@@ -230,13 +231,14 @@ func (cache cacheStore) Close() error {
return cache.s.Close()
}
func getStore(storeType string, nodes []string, database, table string, ttl time.Duration, size int) microstore.Store {
func getStore(cfg Config) microstore.Store {
return store.Create(
store.Store(storeType),
microstore.Nodes(nodes...),
microstore.Database(database),
microstore.Table(table),
store.TTL(ttl),
store.Size(size),
store.Store(cfg.Store),
microstore.Nodes(cfg.Nodes...),
microstore.Database(cfg.Database),
microstore.Table(cfg.Table),
store.TTL(cfg.TTL),
store.Size(cfg.Size),
store.DisablePersistence(cfg.DisablePersistence),
)
}
+5 -6
View File
@@ -20,7 +20,6 @@ package cache
import (
"strings"
"time"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
@@ -32,12 +31,12 @@ type createHomeCache struct {
}
// NewCreateHomeCache creates a new CreateHomeCache
func NewCreateHomeCache(store string, nodes []string, database, table string, ttl time.Duration, size int) CreateHomeCache {
func NewCreateHomeCache(cfg Config) CreateHomeCache {
c := &createHomeCache{}
c.s = getStore(store, nodes, database, table, ttl, size)
c.database = database
c.table = table
c.ttl = ttl
c.s = getStore(cfg)
c.database = cfg.Database
c.table = cfg.Table
c.ttl = cfg.TTL
return c
}
+5 -7
View File
@@ -19,8 +19,6 @@
package cache
import (
"time"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
)
@@ -30,12 +28,12 @@ type createPersonalSpaceCache struct {
}
// NewCreatePersonalSpaceCache creates a new CreatePersonalSpaceCache
func NewCreatePersonalSpaceCache(store string, nodes []string, database, table string, ttl time.Duration, size int) CreatePersonalSpaceCache {
func NewCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache {
c := &createPersonalSpaceCache{}
c.s = getStore(store, nodes, database, table, ttl, size)
c.database = database
c.table = table
c.ttl = ttl
c.s = getStore(cfg)
c.database = cfg.Database
c.table = cfg.Table
c.ttl = cfg.TTL
return c
}
+5 -9
View File
@@ -18,21 +18,17 @@
package cache
import (
"time"
)
type fileMetadataCache struct {
cacheStore
}
// NewFileMetadataCache creates a new FileMetadataCache
func NewFileMetadataCache(store string, nodes []string, database, table string, ttl time.Duration, size int) FileMetadataCache {
func NewFileMetadataCache(cfg Config) FileMetadataCache {
c := &fileMetadataCache{}
c.s = getStore(store, nodes, database, table, ttl, size)
c.database = database
c.table = table
c.ttl = ttl
c.s = getStore(cfg)
c.database = cfg.Database
c.table = cfg.Table
c.ttl = cfg.TTL
return c
}
+5 -6
View File
@@ -20,7 +20,6 @@ package cache
import (
"sync"
"time"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
@@ -33,12 +32,12 @@ type providerCache struct {
}
// NewProviderCache creates a new ProviderCache
func NewProviderCache(store string, nodes []string, database, table string, ttl time.Duration, size int) ProviderCache {
func NewProviderCache(cfg Config) ProviderCache {
c := &providerCache{}
c.s = getStore(store, nodes, database, table, ttl, size)
c.database = database
c.table = table
c.ttl = ttl
c.s = getStore(cfg)
c.database = cfg.Database
c.table = cfg.Table
c.ttl = cfg.TTL
return c
}
+5 -6
View File
@@ -22,7 +22,6 @@ import (
"context"
"strings"
"sync"
"time"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
@@ -40,12 +39,12 @@ func init() {
}
// NewStatCache creates a new StatCache
func NewStatCache(store string, nodes []string, database, table string, ttl time.Duration, size int) StatCache {
func NewStatCache(cfg Config) StatCache {
c := statCache{}
c.s = getStore(store, nodes, database, table, ttl, size)
c.database = database
c.table = table
c.ttl = ttl
c.s = getStore(cfg)
c.database = cfg.Database
c.table = cfg.Table
c.ttl = cfg.TTL
return &c
}
@@ -138,11 +138,12 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (
tp := tree.New(lu, bs, o, store.Create(
store.Store(o.IDCache.Store),
store.TTL(time.Duration(o.IDCache.TTL)*time.Second),
store.TTL(o.IDCache.TTL),
store.Size(o.IDCache.Size),
microstore.Nodes(o.IDCache.Nodes...),
microstore.Database(o.IDCache.Database),
microstore.Table(o.IDCache.Table),
store.DisablePersistence(o.IDCache.DisablePersistence),
))
permissionsSelector, err := pool.PermissionsSelector(o.PermissionsSVC, pool.WithTLSMode(o.PermTLSMode))
@@ -203,7 +204,7 @@ func New(o *options.Options, lu *lookup.Lookup, p Permissions, tp Tree, es event
p: p,
chunkHandler: chunking.NewChunkHandler(filepath.Join(o.Root, "uploads")),
stream: es,
cache: cache.GetStatCache(o.StatCache.Store, o.StatCache.Nodes, o.StatCache.Database, "stat", time.Duration(o.StatCache.TTL)*time.Second, o.StatCache.Size),
cache: cache.GetStatCache(o.StatCache),
UserCache: ttlcache.NewCache(),
userSpaceIndex: userSpaceIndex,
groupSpaceIndex: groupSpaceIndex,
@@ -27,7 +27,6 @@ import (
"path/filepath"
"strconv"
"strings"
"time"
"github.com/cs3org/reva/v2/pkg/storage/cache"
"github.com/google/renameio/v2"
@@ -53,7 +52,7 @@ type readWriteCloseSeekTruncater interface {
func NewMessagePackBackend(rootPath string, o cache.Config) MessagePackBackend {
return MessagePackBackend{
rootPath: filepath.Clean(rootPath),
metaCache: cache.GetFileMetadataCache(o.Store, o.Nodes, o.Database, "filemetadata:", time.Duration(o.TTL)*time.Second, o.Size),
metaCache: cache.GetFileMetadataCache(o),
}
}
+14
View File
@@ -75,3 +75,17 @@ func TTL(val time.Duration) store.Option {
o.Context = context.WithValue(o.Context, ttlContextKey{}, val)
}
}
type disablePersistanceContextKey struct{}
// DisablePersistence disables the persistence of the store by instructing it to use memory only.
// Only supported by the `natsjs` and `natsjskv` implementations.
func DisablePersistence(val bool) store.Option {
return func(o *store.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, disablePersistanceContextKey{}, val)
}
}
+7
View File
@@ -119,6 +119,9 @@ func Create(opts ...microstore.Option) microstore.Store {
return *ocMemStore
case TypeNatsJS:
ttl, _ := options.Context.Value(ttlContextKey{}).(time.Duration)
if mem, _ := options.Context.Value(disablePersistanceContextKey{}).(bool); mem {
opts = append(opts, natsjs.DefaultMemory())
}
// TODO nats needs a DefaultTTL option as it does not support per Write TTL ...
// FIXME nats has restrictions on the key, we cannot use slashes AFAICT
// host, port, clusterid
@@ -132,6 +135,10 @@ func Create(opts ...microstore.Option) microstore.Store {
case TypeNatsJSKV:
// NOTE: nats needs a DefaultTTL option as it does not support per Write TTL ...
ttl, _ := options.Context.Value(ttlContextKey{}).(time.Duration)
if mem, _ := options.Context.Value(disablePersistanceContextKey{}).(bool); mem {
opts = append(opts, natsjskv.DefaultMemory())
}
natsOptions := nats.GetDefaultOptions()
natsOptions.Name = "TODO" // we can pass in the service name to allow identifying the client, but that requires adding a custom context option
return natsjskv.NewStore(
+1 -1
View File
@@ -362,7 +362,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1
github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1
github.com/cs3org/go-cs3apis/cs3/tx/v1beta1
github.com/cs3org/go-cs3apis/cs3/types/v1beta1
# github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f
# github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47
## explicit; go 1.21
github.com/cs3org/reva/v2/cmd/revad/internal/grace
github.com/cs3org/reva/v2/cmd/revad/runtime