2020-09-22 06:51:47 +00:00
|
|
|
package searchsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
|
|
|
objectSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
|
|
|
searchsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/search"
|
|
|
|
objutil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
2020-09-22 06:51:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Service implements Search operation of Object service v2.
|
|
|
|
type Service struct {
|
2023-07-06 09:56:45 +00:00
|
|
|
svc *searchsvc.Service
|
2020-12-10 12:26:40 +00:00
|
|
|
keyStorage *objutil.KeyStorage
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewService constructs Service instance from provided options.
|
2023-07-06 09:56:45 +00:00
|
|
|
func NewService(s *searchsvc.Service, ks *objutil.KeyStorage) *Service {
|
2020-09-22 06:51:47 +00:00
|
|
|
return &Service{
|
2023-07-06 09:56:45 +00:00
|
|
|
svc: s,
|
|
|
|
keyStorage: ks,
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:29:46 +00:00
|
|
|
// Search calls internal service and returns v2 object stream.
|
2020-12-10 12:26:40 +00:00
|
|
|
func (s *Service) Search(req *objectV2.SearchRequest, stream objectSvc.SearchStream) error {
|
|
|
|
p, err := s.toPrm(req, stream)
|
2020-09-22 06:51:47 +00:00
|
|
|
if err != nil {
|
2020-12-10 12:26:40 +00:00
|
|
|
return err
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
return s.svc.Search(stream.Context(), *p)
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|