[#294] deletesvcv2: Refactor service constructor

Pass required deps as args.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-07-06 11:53:18 +03:00 committed by Evgenii Stratonikov
parent 70a1081988
commit a476d8285a
2 changed files with 3 additions and 24 deletions

View file

@ -397,9 +397,7 @@ func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Servi
} }
func createDeleteServiceV2(sDelete *deletesvc.Service) *deletesvcV2.Service { func createDeleteServiceV2(sDelete *deletesvc.Service) *deletesvcV2.Service {
return deletesvcV2.NewService( return deletesvcV2.NewService(sDelete)
deletesvcV2.WithInternalService(sDelete),
)
} }
func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service, func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service,

View file

@ -9,26 +9,13 @@ import (
// Service implements Delete operation of Object service v2. // Service implements Delete operation of Object service v2.
type Service struct { type Service struct {
*cfg
}
// Option represents Service constructor option.
type Option func(*cfg)
type cfg struct {
svc *deletesvc.Service svc *deletesvc.Service
} }
// NewService constructs Service instance from provided options. // NewService constructs Service instance from provided options.
func NewService(opts ...Option) *Service { func NewService(svc *deletesvc.Service) *Service {
c := new(cfg)
for i := range opts {
opts[i](c)
}
return &Service{ return &Service{
cfg: c, svc: svc,
} }
} }
@ -51,9 +38,3 @@ func (s *Service) Delete(ctx context.Context, req *objectV2.DeleteRequest) (*obj
return resp, nil return resp, nil
} }
func WithInternalService(v *deletesvc.Service) Option {
return func(c *cfg) {
c.svc = v
}
}