2020-12-10 12:26:40 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
|
|
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
type searchStreamerV2 struct {
|
|
|
|
objectGRPC.ObjectService_SearchServer
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *searchStreamerV2) Send(resp *object.SearchResponse) error {
|
|
|
|
return s.ObjectService_SearchServer.Send(
|
2021-03-15 10:59:28 +00:00
|
|
|
resp.ToGRPCMessage().(*objectGRPC.SearchResponse),
|
2020-12-10 12:26:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search converts gRPC SearchRequest message and server-side stream and overtakes its data
|
|
|
|
// to gRPC stream.
|
|
|
|
func (s *Server) Search(req *objectGRPC.SearchRequest, gStream objectGRPC.ObjectService_SearchServer) error {
|
2021-03-15 10:59:28 +00:00
|
|
|
searchReq := new(object.SearchRequest)
|
|
|
|
if err := searchReq.FromGRPCMessage(req); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
// TODO: think about how we transport errors through gRPC
|
|
|
|
return s.srv.Search(
|
2021-03-15 10:59:28 +00:00
|
|
|
searchReq,
|
2020-12-10 12:26:40 +00:00
|
|
|
&searchStreamerV2{
|
|
|
|
ObjectService_SearchServer: gStream,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|