From ec9b73846593666629a3c306369b6ddb0d99a912 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 6 Jul 2023 12:31:03 +0300 Subject: [PATCH] [#294] putsvcv2: Refactor service constructor Pass required deps as args. Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/object.go | 5 +---- pkg/services/object/put/v2/service.go | 30 +++------------------------ 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/cmd/frostfs-node/object.go b/cmd/frostfs-node/object.go index 43d68bdcd..37dcc7b3e 100644 --- a/cmd/frostfs-node/object.go +++ b/cmd/frostfs-node/object.go @@ -327,10 +327,7 @@ func createPutSvc(c *cfg, keyStorage *util.KeyStorage) *putsvc.Service { } func createPutSvcV2(sPut *putsvc.Service, keyStorage *util.KeyStorage) *putsvcV2.Service { - return putsvcV2.NewService( - putsvcV2.WithInternalService(sPut), - putsvcV2.WithKeyStorage(keyStorage), - ) + return putsvcV2.NewService(sPut, keyStorage) } func createSearchSvc(c *cfg, keyStorage *util.KeyStorage, traverseGen *util.TraverserGenerator, coreConstructor *cache.ClientCache) *searchsvc.Service { diff --git a/pkg/services/object/put/v2/service.go b/pkg/services/object/put/v2/service.go index 78655edc7..db902ae59 100644 --- a/pkg/services/object/put/v2/service.go +++ b/pkg/services/object/put/v2/service.go @@ -12,27 +12,15 @@ import ( // Service implements Put operation of Object service v2. type Service struct { - *cfg -} - -// Option represents Service constructor option. -type Option func(*cfg) - -type cfg struct { svc *putsvc.Service keyStorage *util.KeyStorage } // NewService constructs Service instance from provided options. -func NewService(opts ...Option) *Service { - c := new(cfg) - - for i := range opts { - opts[i](c) - } - +func NewService(svc *putsvc.Service, ks *util.KeyStorage) *Service { return &Service{ - cfg: c, + svc: svc, + keyStorage: ks, } } @@ -52,15 +40,3 @@ func (s *Service) Put() (object.PutObjectStream, error) { func (s *Service) PutSingle(ctx context.Context, req *objectAPI.PutSingleRequest) (*objectAPI.PutSingleResponse, error) { return s.svc.PutSingle(ctx, req) } - -func WithInternalService(v *putsvc.Service) Option { - return func(c *cfg) { - c.svc = v - } -} - -func WithKeyStorage(ks *util.KeyStorage) Option { - return func(c *cfg) { - c.keyStorage = ks - } -}