frostfs-node/pkg/services/object/get/service.go
Dmitrii Stepanov 30e1b62b67 [#277] getsvc: Fix service deps
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-28 14:03:12 +00:00

54 lines
1.3 KiB
Go

package getsvc
import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"go.uber.org/zap"
)
// Option is a Service's constructor option.
type Option func(*Service)
// Service utility serving requests of Object.Get service.
type Service struct {
log *logger.Logger
localStorage localStorage
traverserGenerator traverserGenerator
epochSource epochSource
keyStore keyStorage
remoteStorageConstructor remoteStorageConstructor
}
// New creates, initializes and returns utility serving
// Object.Get service requests.
func New(
ks keyStorage,
es epochSource,
e localStorageEngine,
tg traverserGenerator,
cc clientConstructor,
opts ...Option,
) *Service {
result := &Service{
keyStore: ks,
epochSource: es,
log: &logger.Logger{Logger: zap.L()},
localStorage: &engineLocalStorage{
engine: e,
},
traverserGenerator: tg,
remoteStorageConstructor: &multiclientRemoteStorageConstructor{
clientConstructor: cc,
},
}
for _, option := range opts {
option(result)
}
return result
}
// WithLogger returns option to specify Get service's logger.
func WithLogger(l *logger.Logger) Option {
return func(s *Service) {
s.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Get service"))}
}
}