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/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
|
||||
|
@ -46,6 +48,7 @@ type (
|
|||
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)
|
||||
|
|
|
@ -36,7 +36,6 @@ type (
|
|||
tls *tlsConfig
|
||||
obj layer.Client
|
||||
api api.Handler
|
||||
nc *notifications.Controller
|
||||
|
||||
maxClients api.MaxClients
|
||||
|
||||
|
@ -155,6 +154,7 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App {
|
|||
Key: randomKey,
|
||||
},
|
||||
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),
|
||||
|
|
Loading…
Reference in a new issue