[#241] object/search: Refactor service processing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-10 15:26:40 +03:00 committed by Alex Vanin
parent 3bfb18386b
commit 611a29f682
23 changed files with 1020 additions and 657 deletions

View file

@ -1,41 +1,22 @@
package searchsvc
import (
"context"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
"github.com/pkg/errors"
"go.uber.org/zap"
)
type localStream struct {
query query.Query
func (exec *execCtx) executeLocal() {
ids, err := exec.svc.localStorage.search(exec)
storage *engine.StorageEngine
cid *container.ID
}
func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) error {
fs := s.query.ToSearchFilters()
addrList, err := engine.Select(s.storage, s.cid, fs)
if err != nil {
return errors.Wrapf(err, "(%T) could not select objects from local storage", s)
exec.status = statusUndefined
exec.err = err
exec.log.Debug("local operation failed",
zap.String("error", err.Error()),
)
return
}
idList := make([]*objectSDK.ID, 0, len(addrList))
for i := range addrList {
idList = append(idList, addrList[i].ObjectID())
}
select {
case <-ctx.Done():
return ctx.Err()
case ch <- idList:
return nil
}
exec.writeIDList(ids)
}