diff --git a/api/layer/layer.go b/api/layer/layer.go index c88339d7..6c710785 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -15,6 +15,7 @@ import ( "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/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/creds/accessbox" "github.com/nspcc-dev/neofs-sdk-go/client" @@ -34,6 +35,7 @@ type ( log *zap.Logger anonKey AnonymousKey resolver *resolver.BucketResolver + ncontroller *notifications.Controller listsCache *cache.ObjectsListCache objCache *cache.ObjectsCache namesCache *cache.ObjectsNameCache @@ -42,10 +44,11 @@ type ( } Config struct { - ChainAddress string - Caches *CachesConfig - AnonKey AnonymousKey - Resolver *resolver.BucketResolver + ChainAddress string + Caches *CachesConfig + AnonKey AnonymousKey + Resolver *resolver.BucketResolver + NotificationController *notifications.Controller } // AnonymousKey contains data for anonymous requests. @@ -264,6 +267,7 @@ func NewLayer(log *zap.Logger, conns pool.Pool, config *Config) Client { anonKey: config.AnonKey, resolver: config.Resolver, listsCache: cache.NewObjectsListCache(config.Caches.ObjectsList), + ncontroller: config.NotificationController, objCache: cache.New(config.Caches.Objects), namesCache: cache.NewObjectsNameCache(config.Caches.Names), bucketCache: cache.NewBucketCache(config.Caches.Buckets), @@ -275,6 +279,10 @@ func (n *layer) EphemeralKey() *keys.PublicKey { return n.anonKey.Key.PublicKey() } +func (n *layer) IsNotificationEnabled() bool { + return n.ncontroller != nil +} + // IsAuthenticatedRequest check if access box exists in current request. func IsAuthenticatedRequest(ctx context.Context) bool { _, ok := ctx.Value(api.BoxData).(*accessbox.Box) diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index f2f076fd..a8a5eb8e 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -36,7 +36,6 @@ type ( tls *tlsConfig obj layer.Client api api.Handler - nc *notifications.Controller maxClients api.MaxClients @@ -154,7 +153,8 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App { AnonKey: layer.AnonymousKey{ Key: randomKey, }, - Resolver: bucketResolver, + Resolver: bucketResolver, + NotificationController: nc, } // prepare object layer @@ -177,7 +177,6 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App { obj: obj, tls: tls, api: caller, - nc: nc, webDone: make(chan struct{}, 1), wrkDone: make(chan struct{}, 1),