forked from TrueCloudLab/frostfs-s3-gw
[#340] Move notification controller to layer
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
8529a7d80b
commit
e0c6544567
2 changed files with 14 additions and 7 deletions
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/cache"
|
"github.com/nspcc-dev/neofs-s3-gw/api/cache"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||||
|
"github.com/nspcc-dev/neofs-s3-gw/api/notifications"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/resolver"
|
"github.com/nspcc-dev/neofs-s3-gw/api/resolver"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/creds/accessbox"
|
"github.com/nspcc-dev/neofs-s3-gw/creds/accessbox"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
|
@ -34,6 +35,7 @@ type (
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
anonKey AnonymousKey
|
anonKey AnonymousKey
|
||||||
resolver *resolver.BucketResolver
|
resolver *resolver.BucketResolver
|
||||||
|
ncontroller *notifications.Controller
|
||||||
listsCache *cache.ObjectsListCache
|
listsCache *cache.ObjectsListCache
|
||||||
objCache *cache.ObjectsCache
|
objCache *cache.ObjectsCache
|
||||||
namesCache *cache.ObjectsNameCache
|
namesCache *cache.ObjectsNameCache
|
||||||
|
@ -42,10 +44,11 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
Config struct {
|
Config struct {
|
||||||
ChainAddress string
|
ChainAddress string
|
||||||
Caches *CachesConfig
|
Caches *CachesConfig
|
||||||
AnonKey AnonymousKey
|
AnonKey AnonymousKey
|
||||||
Resolver *resolver.BucketResolver
|
Resolver *resolver.BucketResolver
|
||||||
|
NotificationController *notifications.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnonymousKey contains data for anonymous requests.
|
// AnonymousKey contains data for anonymous requests.
|
||||||
|
@ -264,6 +267,7 @@ func NewLayer(log *zap.Logger, conns pool.Pool, config *Config) Client {
|
||||||
anonKey: config.AnonKey,
|
anonKey: config.AnonKey,
|
||||||
resolver: config.Resolver,
|
resolver: config.Resolver,
|
||||||
listsCache: cache.NewObjectsListCache(config.Caches.ObjectsList),
|
listsCache: cache.NewObjectsListCache(config.Caches.ObjectsList),
|
||||||
|
ncontroller: config.NotificationController,
|
||||||
objCache: cache.New(config.Caches.Objects),
|
objCache: cache.New(config.Caches.Objects),
|
||||||
namesCache: cache.NewObjectsNameCache(config.Caches.Names),
|
namesCache: cache.NewObjectsNameCache(config.Caches.Names),
|
||||||
bucketCache: cache.NewBucketCache(config.Caches.Buckets),
|
bucketCache: cache.NewBucketCache(config.Caches.Buckets),
|
||||||
|
@ -275,6 +279,10 @@ func (n *layer) EphemeralKey() *keys.PublicKey {
|
||||||
return n.anonKey.Key.PublicKey()
|
return n.anonKey.Key.PublicKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *layer) IsNotificationEnabled() bool {
|
||||||
|
return n.ncontroller != nil
|
||||||
|
}
|
||||||
|
|
||||||
// IsAuthenticatedRequest check if access box exists in current request.
|
// IsAuthenticatedRequest check if access box exists in current request.
|
||||||
func IsAuthenticatedRequest(ctx context.Context) bool {
|
func IsAuthenticatedRequest(ctx context.Context) bool {
|
||||||
_, ok := ctx.Value(api.BoxData).(*accessbox.Box)
|
_, ok := ctx.Value(api.BoxData).(*accessbox.Box)
|
||||||
|
|
|
@ -36,7 +36,6 @@ type (
|
||||||
tls *tlsConfig
|
tls *tlsConfig
|
||||||
obj layer.Client
|
obj layer.Client
|
||||||
api api.Handler
|
api api.Handler
|
||||||
nc *notifications.Controller
|
|
||||||
|
|
||||||
maxClients api.MaxClients
|
maxClients api.MaxClients
|
||||||
|
|
||||||
|
@ -154,7 +153,8 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App {
|
||||||
AnonKey: layer.AnonymousKey{
|
AnonKey: layer.AnonymousKey{
|
||||||
Key: randomKey,
|
Key: randomKey,
|
||||||
},
|
},
|
||||||
Resolver: bucketResolver,
|
Resolver: bucketResolver,
|
||||||
|
NotificationController: nc,
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare object layer
|
// prepare object layer
|
||||||
|
@ -177,7 +177,6 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App {
|
||||||
obj: obj,
|
obj: obj,
|
||||||
tls: tls,
|
tls: tls,
|
||||||
api: caller,
|
api: caller,
|
||||||
nc: nc,
|
|
||||||
|
|
||||||
webDone: make(chan struct{}, 1),
|
webDone: make(chan struct{}, 1),
|
||||||
wrkDone: make(chan struct{}, 1),
|
wrkDone: make(chan struct{}, 1),
|
||||||
|
|
Loading…
Reference in a new issue