milvus/internal/util/streamingutil/status/client_stream_wrapper.go
chyezh 7611128e57
enhance: wal adaptor implementation (#34122)
issue: #33285

- add adaptor to implement walimpls into wal interface.
- implement timetick sorted and filtering scanner.
- add test for wal.

---------

Signed-off-by: chyezh <chyezh@outlook.com>
2024-07-04 15:23:08 +08:00

35 lines
878 B
Go

package status
import (
"google.golang.org/grpc"
)
// NewClientStreamWrapper returns a grpc.ClientStream that wraps the given stream.
func NewClientStreamWrapper(method string, stream grpc.ClientStream) grpc.ClientStream {
if stream == nil {
return nil
}
return &clientStreamWrapper{
method: method,
ClientStream: stream,
}
}
// clientStreamWrapper wraps a grpc.ClientStream and converts errors to Status.
type clientStreamWrapper struct {
method string
grpc.ClientStream
}
// Convert the error to a Status and return it.
func (s *clientStreamWrapper) SendMsg(m interface{}) error {
err := s.ClientStream.SendMsg(m)
return ConvertStreamingError(s.method, err)
}
// Convert the error to a Status and return it.
func (s *clientStreamWrapper) RecvMsg(m interface{}) error {
err := s.ClientStream.RecvMsg(m)
return ConvertStreamingError(s.method, err)
}