forked from TrueCloudLab/frostfs-node
[#294] deletesvcv2: Refactor service constructor
Pass required deps as args. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
70a1081988
commit
a476d8285a
2 changed files with 3 additions and 24 deletions
|
@ -397,9 +397,7 @@ func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Servi
|
|||
}
|
||||
|
||||
func createDeleteServiceV2(sDelete *deletesvc.Service) *deletesvcV2.Service {
|
||||
return deletesvcV2.NewService(
|
||||
deletesvcV2.WithInternalService(sDelete),
|
||||
)
|
||||
return deletesvcV2.NewService(sDelete)
|
||||
}
|
||||
|
||||
func createSplitService(c *cfg, sPutV2 *putsvcV2.Service, sGetV2 *getsvcV2.Service,
|
||||
|
|
|
@ -9,26 +9,13 @@ import (
|
|||
|
||||
// Service implements Delete operation of Object service v2.
|
||||
type Service struct {
|
||||
*cfg
|
||||
}
|
||||
|
||||
// Option represents Service constructor option.
|
||||
type Option func(*cfg)
|
||||
|
||||
type cfg struct {
|
||||
svc *deletesvc.Service
|
||||
}
|
||||
|
||||
// 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 *deletesvc.Service) *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
|
||||
}
|
||||
|
||||
func WithInternalService(v *deletesvc.Service) Option {
|
||||
return func(c *cfg) {
|
||||
c.svc = v
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue