2020-09-22 09:51:47 +03:00
|
|
|
package searchsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 16:38:26 +03: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 09:51:47 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Service implements Search operation of Object service v2.
|
|
|
|
type Service struct {
|
2023-07-06 12:56:45 +03:00
|
|
|
svc *searchsvc.Service
|
2020-12-10 15:26:40 +03:00
|
|
|
keyStorage *objutil.KeyStorage
|
2020-09-22 09:51:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewService constructs Service instance from provided options.
|
2023-07-06 12:56:45 +03:00
|
|
|
func NewService(s *searchsvc.Service, ks *objutil.KeyStorage) *Service {
|
2020-09-22 09:51:47 +03:00
|
|
|
return &Service{
|
2023-07-06 12:56:45 +03:00
|
|
|
svc: s,
|
|
|
|
keyStorage: ks,
|
2020-09-22 09:51:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-23 16:29:46 +03:00
|
|
|
// Search calls internal service and returns v2 object stream.
|
2020-12-10 15:26:40 +03:00
|
|
|
func (s *Service) Search(req *objectV2.SearchRequest, stream objectSvc.SearchStream) error {
|
|
|
|
p, err := s.toPrm(req, stream)
|
2020-09-22 09:51:47 +03:00
|
|
|
if err != nil {
|
2020-12-10 15:26:40 +03:00
|
|
|
return err
|
2020-09-22 09:51:47 +03:00
|
|
|
}
|
|
|
|
|
2020-12-10 15:26:40 +03:00
|
|
|
return s.svc.Search(stream.Context(), *p)
|
2020-09-22 09:51:47 +03:00
|
|
|
}
|