frostfs-node/pkg/services/object/search/service.go
Alexander Chuprov 9b113c3156
Some checks failed
DCO action / DCO (pull_request) Successful in 59s
Vulncheck / Vulncheck (pull_request) Successful in 1m4s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m55s
Build / Build Components (pull_request) Successful in 2m4s
Tests and linters / Staticcheck (pull_request) Successful in 2m38s
Tests and linters / Lint (pull_request) Successful in 3m16s
Tests and linters / Run gofumpt (pull_request) Successful in 3m54s
Tests and linters / Tests (pull_request) Successful in 4m12s
Tests and linters / gopls check (pull_request) Successful in 4m31s
Tests and linters / Tests with -race (pull_request) Successful in 4m38s
OCI image / Build container images (push) Failing after 18s
Vulncheck / Vulncheck (push) Successful in 1m2s
Pre-commit hooks / Pre-commit (push) Successful in 1m39s
Build / Build Components (push) Successful in 1m45s
Tests and linters / Staticcheck (push) Successful in 2m18s
Tests and linters / Run gofumpt (push) Successful in 2m46s
Tests and linters / Lint (push) Successful in 3m5s
Tests and linters / Tests with -race (push) Successful in 3m23s
Tests and linters / Tests (push) Successful in 3m52s
Tests and linters / gopls check (push) Successful in 4m18s
[#1613] morph: Add tracing for morph queries to neo-go
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2025-02-05 16:38:20 +03:00

99 lines
2.5 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(context.Context, cid.ID, *oid.ID, uint64) (*placement.Traverser, *container.Container, error)
}
currentEpochReceiver interface {
Epoch(ctx context.Context) (uint64, error)
}
keyStore *util.KeyStorage
containerSource container.Source
}
// 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,
cs container.Source,
opts ...Option,
) *Service {
c := &cfg{
log: logger.NewLoggerWrapper(zap.L()),
clientConstructor: &clientConstructorWrapper{
constructor: cc,
},
localStorage: &storageEngineWrapper{
storage: e,
},
traverserGenerator: tg,
currentEpochReceiver: ns,
keyStore: ks,
containerSource: cs,
}
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 = l.With(zap.String("component", "Object.Search service"))
}
}