Skip to content

Commit 885ee8d

Browse files
authored
Expose base grpcclient over client interface (dapr#272)
Signed-off-by: Paul Thiele <thielepaul@gmail.com>
1 parent 247a506 commit 885ee8d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

client/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ type Client interface {
166166

167167
// ImplActorClientStub is to impl user defined actor client stub
168168
ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)
169+
170+
// GrpcClient returns the base grpc client if grpc is used and nil otherwise
171+
GrpcClient() pb.DaprClient
169172
}
170173

171174
// NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port.
@@ -308,3 +311,8 @@ func (c *GRPCClient) Shutdown(ctx context.Context) error {
308311
}
309312
return nil
310313
}
314+
315+
// GrpcClient returns the base grpc client.
316+
func (c *GRPCClient) GrpcClient() pb.DaprClient {
317+
return c.protoClient
318+
}

client/client_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,9 @@ func (s *testDaprServer) UnsubscribeConfigurationAlpha1(ctx context.Context, in
415415
delete(s.configurationSubscriptionID, in.Id)
416416
return &pb.UnsubscribeConfigurationResponse{Ok: true}, nil
417417
}
418+
419+
func TestGrpcClient(t *testing.T) {
420+
protoClient := pb.NewDaprClient(nil)
421+
client := &GRPCClient{protoClient: protoClient}
422+
assert.Equal(t, protoClient, client.GrpcClient())
423+
}

0 commit comments

Comments
 (0)