dapr / dapr/java-sdk

Enhance DaprClientBuilder to override gRPC and Http Client

Offen
#683 4 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
P2
Vorherrschende Sprache
Java
Sterne
300
Forks
230
Ø Merge
5 T. 1 Std.
Gemergte PRs (30 T.)
5

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.