-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance DaprClientBuilder to override gRPC and Http Client #683
Comments
The fact that Dapr completely configures and manages the underlying OkHttpClient and gRPC client also prevents frameworks like Spring, OpenTelemetry etc. to do automatic instrumentation of those clients. I guess that being able to configure a |
First, we plan to remove dependency on OKHTTP to avoid version conflicts with Spring and other popular frameworks. So, making that as part of the SDK contract would be going in the other direction. Regarding gRPC managed channel, that could be interesting. Although I would probably create a new builder class to keep the existing one protocol neutral. |
So how daprclient going to support http ? I guess the interfaces have to change to accept a Callable or Function that will take care of http call ? |
We plan to deprecate HTTP client in the next release and only offer gRPC. |
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.
The text was updated successfully, but these errors were encountered: