Skip to content

Commit

Permalink
fix grpc client warn when use streaming grpc interface
Browse files Browse the repository at this point in the history
Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd committed Feb 26, 2024
1 parent e1e87d5 commit 4c3ba3b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 650 deletions.
3 changes: 3 additions & 0 deletions internal/util/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ func (c *ClientBase[T]) call(ctx context.Context, caller func(client T) (any, er
status = res
case interface{ GetStatus() *commonpb.Status }:
status = res.GetStatus()
// streaming call
case grpc.ClientStream:
status = merr.Status(nil)
default:
// it will directly return the result
log.Warn("unknown return type", zap.Any("return", ret))
Expand Down
9 changes: 9 additions & 0 deletions internal/util/grpcclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
"github.com/milvus-io/milvus/internal/util/sessionutil"
"github.com/milvus-io/milvus/internal/util/streamrpc"
"github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/typeutil"
Expand Down Expand Up @@ -170,6 +171,14 @@ func testCall(t *testing.T, compressed bool) {
assert.NoError(t, err)
})

t.Run("Call with stream method", func(t *testing.T) {
initClient()
_, err := base.Call(context.Background(), func(client *mockClient) (any, error) {
return streamrpc.LocalQueryClient{}, nil
})
assert.NoError(t, err)
})

t.Run("Call with canceled context", func(t *testing.T) {
initClient()
ctx, cancel := context.WithCancel(context.Background())
Expand Down
325 changes: 0 additions & 325 deletions internal/util/streamrpc/mocks/mock_query_stream_segments_server.go

This file was deleted.

Loading

0 comments on commit 4c3ba3b

Please sign in to comment.