dapr / dapr/java-sdk

Enhance DaprClientBuilder to override gRPC and Http Client

Open
#683 4 comments 3 reactions 0 assignees View on GitHub
P2
Dominant language
Java
Stars
300
Forks
230
Avg merge
1d 20h
Merged PRs (30d)
4

Description

The gRPC client and http client creation inside DaprClient is not flexible to outside users. For example when creating a grpc client, all the impactful configuration resides inside grpc ManagedChannel where you can set a sizable executor pool, timeouts etc. Same with OkHttpClient.

I locally made changes to cater this requirement. Following is the final look from the dapr client builder point of view.
` DaprClientBuilder daprClientBuilder = new DaprClientBuilder();
ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create())
.executor(Executors.newFixedThreadPool(20));
DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build();`

Same goes for OkHttpClient.

` DaprClientBuilder daprClientBuilder = new DaprClientBuilder();
DaprClient client = daprClientBuilder.withOkHttpClient(new OkHttpClient.Builder().readTimeout(10, TimeUnit.SECONDS)).build();`

I specifically added these methods to DaprClientBuilder directly(even though it's not aware of grpc or http specifically from the interface), to keep the implementation and current code remain same and make this change backward compatible.

Please let me know your thoughts, I can send the official PR based on your feedbacl.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.