From 885ee8d326275675f73f21f9d1e71378d897d9f3 Mon Sep 17 00:00:00 2001 From: thielepaul Date: Thu, 14 Apr 2022 16:04:24 +0200 Subject: [PATCH] Expose base grpcclient over client interface (#272) Signed-off-by: Paul Thiele --- client/client.go | 8 ++++++++ client/client_test.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/client/client.go b/client/client.go index ae43e71..3b14ce2 100644 --- a/client/client.go +++ b/client/client.go @@ -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 +} diff --git a/client/client_test.go b/client/client_test.go index a81ffd7..c55c1ee 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -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()) +}