[#391] Refactor notifications

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-04-29 16:08:22 +03:00 committed by Alex Vanin
parent ea8e1b3b19
commit 94caa2247e
11 changed files with 279 additions and 278 deletions

View file

@ -28,11 +28,9 @@ import (
)
type (
Notificator interface {
EventListener interface {
Subscribe(context.Context, string, MsgHandler) error
Listen(context.Context)
SendNotifications(topics map[string]string, p *SendNotificationParams) error
SendTestNotification(topic, bucketName, requestID, HostID string) error
}
MsgHandler interface {
@ -46,7 +44,7 @@ type (
log *zap.Logger
anonKey AnonymousKey
resolver *resolver.BucketResolver
ncontroller Notificator
ncontroller EventListener
listsCache *cache.ObjectsListCache
objCache *cache.ObjectsCache
namesCache *cache.ObjectsNameCache
@ -192,7 +190,7 @@ type (
// Client provides S3 API client interface.
Client interface {
Initialize(ctx context.Context, c Notificator) error
Initialize(ctx context.Context, c EventListener) error
EphemeralKey() *keys.PublicKey
GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo) (*data.BucketSettings, error)
@ -241,8 +239,6 @@ type (
PutBucketNotificationConfiguration(ctx context.Context, p *PutBucketNotificationConfigurationParams) error
GetBucketNotificationConfiguration(ctx context.Context, bktInfo *data.BucketInfo) (*data.NotificationConfiguration, error)
SendNotifications(ctx context.Context, p *SendNotificationParams) error
}
)
@ -290,7 +286,7 @@ func (n *layer) EphemeralKey() *keys.PublicKey {
return n.anonKey.Key.PublicKey()
}
func (n *layer) Initialize(ctx context.Context, c Notificator) error {
func (n *layer) Initialize(ctx context.Context, c EventListener) error {
if n.IsNotificationEnabled() {
return fmt.Errorf("already initialized")
}