forked from TrueCloudLab/frostfs-node
[#294] deletesvc: Refactor service constructor
Pass required deps as args. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>logs-linter
parent
a476d8285a
commit
1420b8b9ea
|
@ -382,17 +382,17 @@ func createGetServiceV2(sGet *getsvc.Service, keyStorage *util.KeyStorage) *gets
|
||||||
func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Service,
|
func createDeleteService(c *cfg, keyStorage *util.KeyStorage, sGet *getsvc.Service,
|
||||||
sSearch *searchsvc.Service, sPut *putsvc.Service) *deletesvc.Service {
|
sSearch *searchsvc.Service, sPut *putsvc.Service) *deletesvc.Service {
|
||||||
return deletesvc.New(
|
return deletesvc.New(
|
||||||
deletesvc.WithLogger(c.log),
|
sGet,
|
||||||
deletesvc.WithHeadService(sGet),
|
sSearch,
|
||||||
deletesvc.WithSearchService(sSearch),
|
sPut,
|
||||||
deletesvc.WithPutService(sPut),
|
&delNetInfo{
|
||||||
deletesvc.WithNetworkInfo(&delNetInfo{
|
|
||||||
State: c.cfgNetmap.state,
|
State: c.cfgNetmap.state,
|
||||||
tsLifetime: c.cfgObject.tombstoneLifetime,
|
tsLifetime: c.cfgObject.tombstoneLifetime,
|
||||||
|
|
||||||
cfg: c,
|
cfg: c,
|
||||||
}),
|
},
|
||||||
deletesvc.WithKeyStorage(keyStorage),
|
keyStorage,
|
||||||
|
deletesvc.WithLogger(c.log),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,16 +62,22 @@ type cfg struct {
|
||||||
keyStorage *util.KeyStorage
|
keyStorage *util.KeyStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
|
||||||
return &cfg{
|
|
||||||
log: &logger.Logger{Logger: zap.L()},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates, initializes and returns utility serving
|
// New creates, initializes and returns utility serving
|
||||||
// Object.Get service requests.
|
// Object.Get service requests.
|
||||||
func New(opts ...Option) *Service {
|
func New(gs *getsvc.Service,
|
||||||
c := defaultCfg()
|
ss *searchsvc.Service,
|
||||||
|
ps *putsvc.Service,
|
||||||
|
ni NetworkInfo,
|
||||||
|
ks *util.KeyStorage,
|
||||||
|
opts ...Option) *Service {
|
||||||
|
c := &cfg{
|
||||||
|
log: &logger.Logger{Logger: zap.L()},
|
||||||
|
header: (*headSvcWrapper)(gs),
|
||||||
|
searcher: (*searchSvcWrapper)(ss),
|
||||||
|
placer: (*putSvcWrapper)(ps),
|
||||||
|
netInfo: ni,
|
||||||
|
keyStorage: ks,
|
||||||
|
}
|
||||||
|
|
||||||
for i := range opts {
|
for i := range opts {
|
||||||
opts[i](c)
|
opts[i](c)
|
||||||
|
@ -88,39 +94,3 @@ func WithLogger(l *logger.Logger) Option {
|
||||||
c.log = &logger.Logger{Logger: l.With(zap.String("component", "objectSDK.Delete service"))}
|
c.log = &logger.Logger{Logger: l.With(zap.String("component", "objectSDK.Delete service"))}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithHeadService returns option to set Head service
|
|
||||||
// to work with object headers.
|
|
||||||
func WithHeadService(h *getsvc.Service) Option {
|
|
||||||
return func(c *cfg) {
|
|
||||||
c.header = (*headSvcWrapper)(h)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithSearchService returns option to set search service.
|
|
||||||
func WithSearchService(s *searchsvc.Service) Option {
|
|
||||||
return func(c *cfg) {
|
|
||||||
c.searcher = (*searchSvcWrapper)(s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithPutService returns option to specify put service.
|
|
||||||
func WithPutService(p *putsvc.Service) Option {
|
|
||||||
return func(c *cfg) {
|
|
||||||
c.placer = (*putSvcWrapper)(p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithNetworkInfo returns option to set network information source.
|
|
||||||
func WithNetworkInfo(netInfo NetworkInfo) Option {
|
|
||||||
return func(c *cfg) {
|
|
||||||
c.netInfo = netInfo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithKeyStorage returns option to set local private key storage.
|
|
||||||
func WithKeyStorage(ks *util.KeyStorage) Option {
|
|
||||||
return func(c *cfg) {
|
|
||||||
c.keyStorage = ks
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue