forked from TrueCloudLab/frostfs-node
Dmitrii Stepanov
fc383ea6ae
Now EC objects assembling is performed concurrently. Also fixed issue with an error in case of getting EC object via non-container node. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
95 lines
2.4 KiB
Go
95 lines
2.4 KiB
Go
package searchsvc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// Service is an utility serving requests
|
|
// of Object.Search service.
|
|
type Service struct {
|
|
*cfg
|
|
}
|
|
|
|
// Option is a Service's constructor option.
|
|
type Option func(*cfg)
|
|
|
|
type searchClient interface {
|
|
// searchObjects searches objects on the specified node.
|
|
// MUST NOT modify execCtx as it can be accessed concurrently.
|
|
searchObjects(context.Context, *execCtx, client.NodeInfo) ([]oid.ID, error)
|
|
}
|
|
|
|
type ClientConstructor interface {
|
|
Get(client.NodeInfo) (client.MultiAddressClient, error)
|
|
}
|
|
|
|
type cfg struct {
|
|
log *logger.Logger
|
|
|
|
localStorage interface {
|
|
search(context.Context, *execCtx) ([]oid.ID, error)
|
|
}
|
|
|
|
clientConstructor interface {
|
|
get(client.NodeInfo) (searchClient, error)
|
|
}
|
|
|
|
traverserGenerator interface {
|
|
GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, *container.Container, error)
|
|
}
|
|
|
|
currentEpochReceiver interface {
|
|
Epoch() (uint64, error)
|
|
}
|
|
|
|
keyStore *util.KeyStorage
|
|
}
|
|
|
|
// New creates, initializes and returns utility serving
|
|
// Object.Get service requests.
|
|
func New(e *engine.StorageEngine,
|
|
cc ClientConstructor,
|
|
tg *util.TraverserGenerator,
|
|
ns netmap.Source,
|
|
ks *util.KeyStorage,
|
|
opts ...Option,
|
|
) *Service {
|
|
c := &cfg{
|
|
log: &logger.Logger{Logger: zap.L()},
|
|
clientConstructor: &clientConstructorWrapper{
|
|
constructor: cc,
|
|
},
|
|
localStorage: &storageEngineWrapper{
|
|
storage: e,
|
|
},
|
|
traverserGenerator: tg,
|
|
currentEpochReceiver: ns,
|
|
keyStore: ks,
|
|
}
|
|
|
|
for i := range opts {
|
|
opts[i](c)
|
|
}
|
|
|
|
return &Service{
|
|
cfg: c,
|
|
}
|
|
}
|
|
|
|
// WithLogger returns option to specify Get service's logger.
|
|
func WithLogger(l *logger.Logger) Option {
|
|
return func(c *cfg) {
|
|
c.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Search service"))}
|
|
}
|
|
}
|