dapr / dapr/java-sdk

Enhance DaprClientBuilder to override gRPC and Http Client

Aperta
#683 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub
P2
Lingua principale
Java
Stelle
300
Fork
230
Merge medio
5g 1h
PR unite (30g)
5

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.