@@ -1921,7 +1921,6 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on =
|
|||||||
"MICRO_REGISTRY_ADDRESS": "127.0.0.1:9233",
|
"MICRO_REGISTRY_ADDRESS": "127.0.0.1:9233",
|
||||||
"OCIS_CACHE_STORE": "nats-js-kv",
|
"OCIS_CACHE_STORE": "nats-js-kv",
|
||||||
"OCIS_CACHE_STORE_NODES": "127.0.0.1:9233",
|
"OCIS_CACHE_STORE_NODES": "127.0.0.1:9233",
|
||||||
"OCIS_CACHE_DATABASE": "cache",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if deploy_type == "":
|
if deploy_type == "":
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Enhancement: Bump reva
|
||||||
|
|
||||||
|
Bumps reva version
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/7793
|
||||||
@@ -35,7 +35,7 @@ require (
|
|||||||
github.com/go-micro/plugins/v4/registry/nats v1.2.2-0.20230723205323-1ada01245674
|
github.com/go-micro/plugins/v4/registry/nats v1.2.2-0.20230723205323-1ada01245674
|
||||||
github.com/go-micro/plugins/v4/server/grpc v1.2.0
|
github.com/go-micro/plugins/v4/server/grpc v1.2.0
|
||||||
github.com/go-micro/plugins/v4/server/http v1.2.2
|
github.com/go-micro/plugins/v4/server/http v1.2.2
|
||||||
github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20230807070816-bc05fb076ce7
|
github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20231129143103-d72facc652f0
|
||||||
github.com/go-micro/plugins/v4/wrapper/breaker/gobreaker v1.2.0
|
github.com/go-micro/plugins/v4/wrapper/breaker/gobreaker v1.2.0
|
||||||
github.com/go-micro/plugins/v4/wrapper/monitoring/prometheus v1.2.0
|
github.com/go-micro/plugins/v4/wrapper/monitoring/prometheus v1.2.0
|
||||||
github.com/go-micro/plugins/v4/wrapper/trace/opentelemetry v1.2.0
|
github.com/go-micro/plugins/v4/wrapper/trace/opentelemetry v1.2.0
|
||||||
@@ -347,6 +347,4 @@ require (
|
|||||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a
|
|
||||||
|
|
||||||
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
||||||
|
|||||||
@@ -1213,6 +1213,8 @@ github.com/go-micro/plugins/v4/server/grpc v1.2.0 h1:lXfM+/0oE/u1g0hVBYsvbP4lYOY
|
|||||||
github.com/go-micro/plugins/v4/server/grpc v1.2.0/go.mod h1:+Ah9Pf/vMSXxBM3fup/hc3N+zN2as3nIpcRaR4sBjnY=
|
github.com/go-micro/plugins/v4/server/grpc v1.2.0/go.mod h1:+Ah9Pf/vMSXxBM3fup/hc3N+zN2as3nIpcRaR4sBjnY=
|
||||||
github.com/go-micro/plugins/v4/server/http v1.2.2 h1:UK2/09AU0zV3wHELuR72TZzVU2vTUhbx9qrRGrQSIWg=
|
github.com/go-micro/plugins/v4/server/http v1.2.2 h1:UK2/09AU0zV3wHELuR72TZzVU2vTUhbx9qrRGrQSIWg=
|
||||||
github.com/go-micro/plugins/v4/server/http v1.2.2/go.mod h1:YuAjaSPxcn3LI8j2FUsqx0Rxunrj4YwDV41Ax76rLl0=
|
github.com/go-micro/plugins/v4/server/http v1.2.2/go.mod h1:YuAjaSPxcn3LI8j2FUsqx0Rxunrj4YwDV41Ax76rLl0=
|
||||||
|
github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20231129143103-d72facc652f0 h1:Qa1EBQ9UyCGecFAJQovl/MHGnvbcvDaM3qUoAG5Lnvk=
|
||||||
|
github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20231129143103-d72facc652f0/go.mod h1:aCRl8JQmqIaonOl88nFPY/BOQnHPVHY9ngStzLkXnYk=
|
||||||
github.com/go-micro/plugins/v4/store/redis v1.2.1-0.20230510195111-07cd57e1bc9d h1:HQoDDVyMfdkrgXNo03ZY4vzhoOXMDZVZ4SnpBDVID6E=
|
github.com/go-micro/plugins/v4/store/redis v1.2.1-0.20230510195111-07cd57e1bc9d h1:HQoDDVyMfdkrgXNo03ZY4vzhoOXMDZVZ4SnpBDVID6E=
|
||||||
github.com/go-micro/plugins/v4/store/redis v1.2.1-0.20230510195111-07cd57e1bc9d/go.mod h1:MbCG0YiyPqETTtm7uHFmxQNCaW1o9hBoYtFwhbVjLUg=
|
github.com/go-micro/plugins/v4/store/redis v1.2.1-0.20230510195111-07cd57e1bc9d/go.mod h1:MbCG0YiyPqETTtm7uHFmxQNCaW1o9hBoYtFwhbVjLUg=
|
||||||
github.com/go-micro/plugins/v4/transport/grpc v1.1.0 h1:mXfDYfFQLnVDzjGY3o84oe4prfux9h8txsnA19dKsj8=
|
github.com/go-micro/plugins/v4/transport/grpc v1.1.0 h1:mXfDYfFQLnVDzjGY3o84oe4prfux9h8txsnA19dKsj8=
|
||||||
@@ -1593,8 +1595,6 @@ github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
|
|||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0=
|
github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0=
|
||||||
github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||||
github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a h1:W+itvdTLFGLuFh+E5IzW08n2BS02cHK91qnMo7SUxbA=
|
|
||||||
github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a/go.mod h1:wt51O2yNmgF/F7E00IYIH0awseRGqtnmjZGn6RjbZSk=
|
|
||||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348 h1:Czv6AW9Suj6npWd5BLZjobdD78c2RdzBeKBgkq3jYZk=
|
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348 h1:Czv6AW9Suj6npWd5BLZjobdD78c2RdzBeKBgkq3jYZk=
|
||||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348/go.mod h1:Goi4eJ9SrKkxE6NsAVqBVNxfQFbwb7UbyII6743ldgM=
|
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348/go.mod h1:Goi4eJ9SrKkxE6NsAVqBVNxfQFbwb7UbyII6743ldgM=
|
||||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ func DefaultConfig() *config.Config {
|
|||||||
SharePrefix: "/Shares",
|
SharePrefix: "/Shares",
|
||||||
HomeNamespace: "/users/{{.Id.OpaqueId}}",
|
HomeNamespace: "/users/{{.Id.OpaqueId}}",
|
||||||
AdditionalInfoAttribute: "{{.Mail}}",
|
AdditionalInfoAttribute: "{{.Mail}}",
|
||||||
StatCacheType: "noop",
|
StatCacheType: "nats-js-kv",
|
||||||
StatCacheDatabase: "ocis",
|
StatCacheDatabase: "cache-stat",
|
||||||
StatCacheTTL: 300 * time.Second,
|
StatCacheTTL: 300 * time.Second,
|
||||||
ListOCMShares: true,
|
ListOCMShares: true,
|
||||||
PublicShareMustHavePassword: true,
|
PublicShareMustHavePassword: true,
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ type Cache struct {
|
|||||||
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
|
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
|
||||||
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_STAT_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details."`
|
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_STAT_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details."`
|
||||||
StatCacheSize int `yaml:"stat_cache_size" env:"OCIS_CACHE_SIZE;GATEWAY_STAT_CACHE_SIZE" desc:"The maximum quantity of items in the cache. Only applies when store type 'ocmem' is configured. Defaults to 512 which is derived from the ocmem package though not exclicitely set as default."`
|
StatCacheSize int `yaml:"stat_cache_size" env:"OCIS_CACHE_SIZE;GATEWAY_STAT_CACHE_SIZE" desc:"The maximum quantity of items in the cache. Only applies when store type 'ocmem' is configured. Defaults to 512 which is derived from the ocmem package though not exclicitely set as default."`
|
||||||
ProviderCacheStore string `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'ocmem', 'etcd', 'redis', 'redis-sentinel', 'nats-js', 'noop'. See the text description for details."`
|
ProviderCacheStore string // `yaml:"provider_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_PROVIDER_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'ocmem', 'etcd', 'redis', 'redis-sentinel', 'nats-js', 'noop'. See the text description for details."`
|
||||||
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' or 'ocmem' stores are configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details."`
|
ProviderCacheNodes []string `yaml:"provider_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_PROVIDER_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' or 'ocmem' stores are configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details."`
|
||||||
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
|
ProviderCacheDatabase string `yaml:"provider_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
|
||||||
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details."`
|
ProviderCacheTTL time.Duration `yaml:"provider_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_PROVIDER_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details."`
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ func DefaultConfig() *config.Config {
|
|||||||
DisableHomeCreationOnLogin: true,
|
DisableHomeCreationOnLogin: true,
|
||||||
TransferExpires: 24 * 60 * 60,
|
TransferExpires: 24 * 60 * 60,
|
||||||
Cache: config.Cache{
|
Cache: config.Cache{
|
||||||
StatCacheStore: "noop",
|
StatCacheStore: "noop", // NOTE: stat cache not working
|
||||||
StatCacheDatabase: "ocis",
|
StatCacheDatabase: "ocis",
|
||||||
StatCacheTTL: 300 * time.Second,
|
StatCacheTTL: 300 * time.Second,
|
||||||
ProviderCacheStore: "noop",
|
ProviderCacheStore: "noop",
|
||||||
ProviderCacheDatabase: "ocis",
|
ProviderCacheDatabase: "cache-providers",
|
||||||
ProviderCacheTTL: 300 * time.Second,
|
ProviderCacheTTL: 300 * time.Second,
|
||||||
CreateHomeCacheStore: "noop",
|
CreateHomeCacheStore: "nats-js-kv",
|
||||||
CreateHomeCacheDatabase: "ocis",
|
CreateHomeCacheDatabase: "cache-createhome",
|
||||||
CreateHomeCacheTTL: 300 * time.Second,
|
CreateHomeCacheTTL: 300 * time.Second,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ func DefaultConfig() *config.Config {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Cache: &config.Cache{
|
Cache: &config.Cache{
|
||||||
Store: "memory",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "cache-roles",
|
||||||
Table: "roles",
|
Table: "roles",
|
||||||
TTL: time.Hour * 336,
|
TTL: time.Hour * 336,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ func DefaultConfig() *config.Config {
|
|||||||
AccessTokenVerifyMethod: config.AccessTokenVerificationJWT,
|
AccessTokenVerifyMethod: config.AccessTokenVerificationJWT,
|
||||||
SkipUserInfo: false,
|
SkipUserInfo: false,
|
||||||
UserinfoCache: &config.Cache{
|
UserinfoCache: &config.Cache{
|
||||||
Store: "memory",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "cache-userinfo",
|
||||||
Table: "userinfo",
|
Table: "userinfo",
|
||||||
TTL: time.Second * 10,
|
TTL: time.Second * 10,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ func DefaultConfig() *config.Config {
|
|||||||
StorageAddress: "com.owncloud.api.storage-system",
|
StorageAddress: "com.owncloud.api.storage-system",
|
||||||
SystemUserIDP: "internal",
|
SystemUserIDP: "internal",
|
||||||
Cache: &config.Cache{
|
Cache: &config.Cache{
|
||||||
Store: "memory",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "settings-cache",
|
||||||
FileTable: "settings_files",
|
FileTable: "settings_files",
|
||||||
DirectoryTable: "settings_dirs",
|
DirectoryTable: "settings_dirs",
|
||||||
TTL: time.Minute * 10,
|
TTL: time.Minute * 10,
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ func DefaultConfig() *config.Config {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
FileMetadataCache: config.Cache{
|
FileMetadataCache: config.Cache{
|
||||||
Store: "memory",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "cache-filemetadata",
|
||||||
TTL: 24 * 60 * time.Second,
|
TTL: 24 * 60 * time.Second,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ func DefaultConfig() *config.Config {
|
|||||||
TTL: 300 * time.Second,
|
TTL: 300 * time.Second,
|
||||||
},
|
},
|
||||||
FilemetadataCache: config.FilemetadataCache{
|
FilemetadataCache: config.FilemetadataCache{
|
||||||
Store: "memory",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "cache-filemetadata",
|
||||||
TTL: 24 * 60 * time.Second,
|
TTL: 24 * 60 * time.Second,
|
||||||
},
|
},
|
||||||
IDCache: config.IDCache{
|
IDCache: config.IDCache{
|
||||||
Store: "nats-js-kv",
|
Store: "nats-js-kv",
|
||||||
Database: "ocis",
|
Database: "ids-storage-users",
|
||||||
TTL: 24 * 60 * time.Second,
|
TTL: 24 * 60 * time.Second,
|
||||||
},
|
},
|
||||||
Tasks: config.Tasks{
|
Tasks: config.Tasks{
|
||||||
|
|||||||
Generated
Vendored
+7
-2
@@ -275,7 +275,9 @@ func (MessagePackBackend) IsMetaFile(path string) bool {
|
|||||||
|
|
||||||
// Purge purges the data of a given path
|
// Purge purges the data of a given path
|
||||||
func (b MessagePackBackend) Purge(path string) error {
|
func (b MessagePackBackend) Purge(path string) error {
|
||||||
_ = b.metaCache.RemoveMetadata(b.cacheKey(path))
|
if err := b.metaCache.RemoveMetadata(b.cacheKey(path)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return os.Remove(b.MetadataPath(path))
|
return os.Remove(b.MetadataPath(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +291,10 @@ func (b MessagePackBackend) Rename(oldPath, newPath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = b.metaCache.RemoveMetadata(b.cacheKey(oldPath))
|
err = b.metaCache.RemoveMetadata(b.cacheKey(oldPath))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return os.Rename(b.MetadataPath(oldPath), b.MetadataPath(newPath))
|
return os.Rename(b.MetadataPath(oldPath), b.MetadataPath(newPath))
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-16
@@ -9,6 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cornelk/hashmap"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go-micro.dev/v4/store"
|
"go-micro.dev/v4/store"
|
||||||
@@ -34,7 +35,7 @@ type natsStore struct {
|
|||||||
|
|
||||||
conn *nats.Conn
|
conn *nats.Conn
|
||||||
js nats.JetStreamContext
|
js nats.JetStreamContext
|
||||||
buckets *sync.Map
|
buckets *hashmap.Map[string, nats.ObjectStore]
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -55,7 +56,7 @@ func NewStore(opts ...store.Option) store.Store {
|
|||||||
opts: options,
|
opts: options,
|
||||||
jsopts: []nats.JSOpt{},
|
jsopts: []nats.JSOpt{},
|
||||||
objStoreConfigs: []*nats.ObjectStoreConfig{},
|
objStoreConfigs: []*nats.ObjectStoreConfig{},
|
||||||
buckets: &sync.Map{},
|
buckets: hashmap.New[string, nats.ObjectStore](),
|
||||||
storageType: nats.FileStorage,
|
storageType: nats.FileStorage,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ func (n *natsStore) Init(opts ...store.Option) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "Failed to create bucket (%s)", cfg.Bucket)
|
return errors.Wrapf(err, "Failed to create bucket (%s)", cfg.Bucket)
|
||||||
}
|
}
|
||||||
n.buckets.Store(cfg.Bucket, store)
|
n.buckets.Set(cfg.Bucket, store)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -178,11 +179,10 @@ func (n *natsStore) Read(key string, opts ...store.ReadOption) ([]*store.Record,
|
|||||||
opt.Table = n.opts.Table
|
opt.Table = n.opts.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
b, ok := n.buckets.Load(opt.Database)
|
bucket, ok := n.buckets.Get(opt.Database)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrBucketNotFound
|
return nil, ErrBucketNotFound
|
||||||
}
|
}
|
||||||
bucket := b.(nats.ObjectStore)
|
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
|
|
||||||
@@ -292,8 +292,7 @@ func (n *natsStore) Write(r *store.Record, opts ...store.WriteOption) error {
|
|||||||
opt.Table = n.opts.Table
|
opt.Table = n.opts.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
s, ok := n.buckets.Load(opt.Database)
|
store, ok := n.buckets.Get(opt.Database)
|
||||||
store, _ := s.(nats.ObjectStore)
|
|
||||||
// Create new bucket if not exists
|
// Create new bucket if not exists
|
||||||
if !ok {
|
if !ok {
|
||||||
var err error
|
var err error
|
||||||
@@ -345,19 +344,18 @@ func (n *natsStore) Delete(key string, opts ...store.DeleteOption) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opt.Table == "DELETE_BUCKET" {
|
if opt.Table == "DELETE_BUCKET" {
|
||||||
n.buckets.Delete(key)
|
n.buckets.Del(key)
|
||||||
if err := n.js.DeleteObjectStore(key); err != nil {
|
if err := n.js.DeleteObjectStore(key); err != nil {
|
||||||
return errors.Wrap(err, "Failed to delete bucket")
|
return errors.Wrap(err, "Failed to delete bucket")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
s, ok := n.buckets.Load(opt.Database)
|
store, ok := n.buckets.Get(opt.Database)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrBucketNotFound
|
return ErrBucketNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
store := s.(nats.ObjectStore)
|
|
||||||
if err := store.Delete(getKey(key, opt.Table)); err != nil {
|
if err := store.Delete(getKey(key, opt.Table)); err != nil {
|
||||||
return errors.Wrap(err, "Failed to delete data")
|
return errors.Wrap(err, "Failed to delete data")
|
||||||
}
|
}
|
||||||
@@ -383,11 +381,10 @@ func (n *natsStore) List(opts ...store.ListOption) ([]string, error) {
|
|||||||
opt.Table = n.opts.Table
|
opt.Table = n.opts.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
s, ok := n.buckets.Load(opt.Database)
|
store, ok := n.buckets.Get(opt.Database)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrBucketNotFound
|
return nil, ErrBucketNotFound
|
||||||
}
|
}
|
||||||
store := s.(nats.ObjectStore)
|
|
||||||
|
|
||||||
objects, err := store.List()
|
objects, err := store.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -405,13 +402,14 @@ func (n *natsStore) List(opts ...store.ListOption) ([]string, error) {
|
|||||||
if !strings.HasSuffix(key, opt.Suffix) {
|
if !strings.HasSuffix(key, opt.Suffix) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
keys = append(keys, key)
|
|
||||||
|
keys = append(keys, strings.TrimPrefix(key, getKey(opt.Prefix, opt.Table)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.Limit > 0 {
|
if opt.Limit > 0 && int(opt.Offset+opt.Limit) < len(keys) {
|
||||||
return keys[opt.Offset : opt.Offset+opt.Limit], nil
|
return keys[opt.Offset : opt.Offset+opt.Limit], nil
|
||||||
}
|
}
|
||||||
if opt.Offset > 0 {
|
if opt.Offset > 0 && int(opt.Offset) < len(keys) {
|
||||||
return keys[opt.Offset:], nil
|
return keys[opt.Offset:], nil
|
||||||
}
|
}
|
||||||
return keys, nil
|
return keys, nil
|
||||||
@@ -448,7 +446,7 @@ func (n *natsStore) createNewBucket(name string) (nats.ObjectStore, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "Failed to create new bucket (%s)", name)
|
return nil, errors.Wrapf(err, "Failed to create new bucket (%s)", name)
|
||||||
}
|
}
|
||||||
n.buckets.Store(name, store)
|
n.buckets.Set(name, store)
|
||||||
return store, err
|
return store, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-3
@@ -937,8 +937,8 @@ github.com/go-micro/plugins/v4/server/grpc
|
|||||||
# github.com/go-micro/plugins/v4/server/http v1.2.2
|
# github.com/go-micro/plugins/v4/server/http v1.2.2
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
github.com/go-micro/plugins/v4/server/http
|
github.com/go-micro/plugins/v4/server/http
|
||||||
# github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20230807070816-bc05fb076ce7 => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a
|
# github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20231129143103-d72facc652f0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.21
|
||||||
github.com/go-micro/plugins/v4/store/nats-js
|
github.com/go-micro/plugins/v4/store/nats-js
|
||||||
# github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-00010101000000-000000000000 => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
# github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-00010101000000-000000000000 => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
||||||
## explicit; go 1.21
|
## explicit; go 1.21
|
||||||
@@ -2297,5 +2297,4 @@ stash.kopano.io/kgol/oidc-go
|
|||||||
# stash.kopano.io/kgol/rndm v1.1.2
|
# stash.kopano.io/kgol/rndm v1.1.2
|
||||||
## explicit; go 1.13
|
## explicit; go 1.13
|
||||||
stash.kopano.io/kgol/rndm
|
stash.kopano.io/kgol/rndm
|
||||||
# github.com/go-micro/plugins/v4/store/nats-js => github.com/kobergj/plugins/v4/store/nats-js v1.2.1-0.20231020092801-9463c820c19a
|
|
||||||
# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
|
||||||
|
|||||||
Reference in New Issue
Block a user