Blocking calls for gRPC and HTTP even though using Reactor
See original GitHub issueExpected Behavior
Implementations of DaprClient API being non-blocking.
Actual Behavior
DaprClient API is reactive with Reactor. However, its implementations (gPRC and HTTP/1.x) at the moment are blocking, which defeats the purpose of using Reactive API. gRPC:
return Mono.fromCallable(wrap(context, () -> {
ListenableFuture<DaprProtos.GetStateResponse> futureResponse = client.getState(envelope);
return buildStateKeyValue(get(futureResponse), key, options, type);
})).map(s -> new Response<>(context, s));
private static <V> V get(ListenableFuture<V> future) {
try {
return future.get();
} catch (Exception e) {
DaprException.wrap(e);
}
return null;
}
public Mono<Response> invokeApi(
String method,
String[] pathSegments,
Map<String, String> urlParameters,
byte[] content,
Map<String, String> headers,
Context context) {
return Mono.fromCallable(() -> doInvokeApi(method, pathSegments, urlParameters, content, headers, context));
}
Note Mono.fromCallable
only adapts the API to reactive. It still blocks a thread, be it the calling thread or the thread the Mono is subscribed on.
Steps to Reproduce the Problem
Release Note
RELEASE NOTE: FIXED implementations of DaprClient API were blocking for gRPC and HTTP.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Fully Reactive Request Processing with Project Reactor ...
Using Reactor bindings allows our code to more clearly express the cardinality between requests and responses, which is one-to-one (unary) in ...
Read more >Performance Best Practices - gRPC
A user guide of both general and language-specific best practices to improve performance.
Read more >Executing Blocking calls on a Reactor based Application
We used HttpsURLConnection since we know for sure that it is a blocking call. To do so we need a Scheduler. For the...
Read more >Can I pass reactor Context into grpc clientInterceptor implicitly?
I came up with another solution that doesn't require a WebFilter or ... response = grpcStub .call(request); return Mono.just(response.
Read more >Spring Cloud Gateway and gRPC
Even though reactor -netty has support for H2C clear-text protocol, Spring Cloud Gateway requires H2 with TLS to assure transport security. HTTP/ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Async is natively supported by gRPC java. HTTP/1.x is much more complicated. I’ll PR for gRPC.
Thanks, @xiazuojie.
We only need the fix for HTTP now. GRPC is fixed.
On a side note, HTTP actually might become more relevant soon. As we are discussing if the invoke API should only be used over HTTP since gRPC to HTTP invocation cannot get the response to client easily translated due to core differences between the protocols.