Expose base grpcclient over client interface (#272)

Signed-off-by: Paul Thiele <thielepaul@gmail.com>
This commit is contained in:
thielepaul 2022-04-14 16:04:24 +02:00 committed by GitHub
parent 247a506004
commit 885ee8d326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -166,6 +166,9 @@ type Client interface {
// ImplActorClientStub is to impl user defined actor client stub
ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)
// GrpcClient returns the base grpc client if grpc is used and nil otherwise
GrpcClient() pb.DaprClient
}
// NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port.
@ -308,3 +311,8 @@ func (c *GRPCClient) Shutdown(ctx context.Context) error {
}
return nil
}
// GrpcClient returns the base grpc client.
func (c *GRPCClient) GrpcClient() pb.DaprClient {
return c.protoClient
}

View File

@ -415,3 +415,9 @@ func (s *testDaprServer) UnsubscribeConfigurationAlpha1(ctx context.Context, in
delete(s.configurationSubscriptionID, in.Id)
return &pb.UnsubscribeConfigurationResponse{Ok: true}, nil
}
func TestGrpcClient(t *testing.T) {
protoClient := pb.NewDaprClient(nil)
client := &GRPCClient{protoClient: protoClient}
assert.Equal(t, protoClient, client.GrpcClient())
}