Skip to content

Enhance DaprClientBuilder to override gRPC and Http Client #683

Open
@subash89

Description

@subash89

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions