Polishing contribution

Closes gh-30403
This commit is contained in:
rstoyanchev
2023-05-03 20:49:20 +01:00
parent 033548a760
commit 73d30dd875
6 changed files with 53 additions and 50 deletions

View File

@@ -73,8 +73,7 @@ final class RSocketServiceMethod {
this.parameters = initMethodParameters(method);
this.argumentResolvers = argumentResolvers;
this.route = initRoute(method, containingClass, rsocketRequester.strategies(), embeddedValueResolver);
this.responseFunction = initResponseFunction(
rsocketRequester, method, reactiveRegistry, blockTimeout);
this.responseFunction = initResponseFunction(rsocketRequester, method, reactiveRegistry, blockTimeout);
}
private static MethodParameter[] initMethodParameters(Method method) {
@@ -163,11 +162,16 @@ final class RSocketServiceMethod {
if (reactiveAdapter != null) {
return reactiveAdapter.fromPublisher(responsePublisher);
}
return (blockForOptional ?
(blockTimeout != null ? ((Mono<?>) responsePublisher).blockOptional(blockTimeout) :
((Mono<?>) responsePublisher).blockOptional()) :
(blockTimeout != null ? ((Mono<?>) responsePublisher).block(blockTimeout) :
((Mono<?>) responsePublisher).block()));
if (blockForOptional) {
return (blockTimeout != null ?
((Mono<?>) responsePublisher).blockOptional(blockTimeout) :
((Mono<?>) responsePublisher).blockOptional());
}
else {
return (blockTimeout != null ?
((Mono<?>) responsePublisher).block(blockTimeout) :
((Mono<?>) responsePublisher).block());
}
});
}

View File

@@ -188,14 +188,17 @@ public final class RSocketServiceProxyFactory {
}
/**
* Configure how long to wait for a response for an HTTP service method
* Configure how long to block for the response of an RSocket service method
* with a synchronous (blocking) method signature.
* <p>By default this is {@code null},
* in which case means blocking on publishers is done without a timeout.
* <p>By default this is not set, in which case the behavior depends on
* connection and response timeout settings of the underlying RSocket
* {@code ClientTransport} as well as RSocket keep-alive settings.
* We recommend configuring timeout values at the RSocket level which
* provides more control.
* @param blockTimeout the timeout value
* @return this same builder instance
*/
public Builder blockTimeout(Duration blockTimeout) {
public Builder blockTimeout(@Nullable Duration blockTimeout) {
this.blockTimeout = blockTimeout;
return this;
}
@@ -208,8 +211,7 @@ public final class RSocketServiceProxyFactory {
return new RSocketServiceProxyFactory(
this.rsocketRequester, initArgumentResolvers(),
this.embeddedValueResolver, this.reactiveAdapterRegistry,
this.blockTimeout);
this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout);
}
private List<RSocketServiceArgumentResolver> initArgumentResolvers() {