Anton Nikiforov
112a7c690f
All checks were successful
DCO action / DCO (pull_request) Successful in 1m44s
Vulncheck / Vulncheck (pull_request) Successful in 3m3s
Build / Build Components (1.21) (pull_request) Successful in 4m0s
Build / Build Components (1.22) (pull_request) Successful in 3m57s
Tests and linters / Staticcheck (pull_request) Successful in 4m46s
Tests and linters / gopls check (pull_request) Successful in 4m48s
Tests and linters / Lint (pull_request) Successful in 5m45s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m57s
Tests and linters / Tests with -race (pull_request) Successful in 9m10s
Tests and linters / Tests (1.22) (pull_request) Successful in 9m20s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package getsvc
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
"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
|
|
containerSource container.Source
|
|
}
|
|
|
|
// New creates, initializes and returns utility serving
|
|
// Object.Get service requests.
|
|
func New(
|
|
ks keyStorage,
|
|
es epochSource,
|
|
e localStorageEngine,
|
|
tg traverserGenerator,
|
|
cc clientConstructor,
|
|
cs container.Source,
|
|
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,
|
|
},
|
|
containerSource: cs,
|
|
}
|
|
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"))}
|
|
}
|
|
}
|