Introduce ClientRSocketConnector.getRequester()

* Restore `Mono<RSocketRequester> getRSocketRequester()` on
`ClientRSocketConnector` and deprecate it in favor of newly introduced
`RSocketRequester getRequester()`: there is no need in wrapping a
`RSocketRequester` to deferred `Mono` since internal logic of the
`RSocketRequester` on client side is based on lazy-load API of the
`RSocketClient`
This commit is contained in:
Artem Bilan
2020-07-22 10:25:47 -04:00
parent 2c42c9181d
commit 730c157064
4 changed files with 21 additions and 6 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.util.MimeType;
import io.rsocket.transport.ClientTransport;
import io.rsocket.transport.netty.client.TcpClientTransport;
import io.rsocket.transport.netty.client.WebsocketClientTransport;
import reactor.core.publisher.Mono;
/**
* A client {@link AbstractRSocketConnector} extension to the RSocket connection.
@@ -210,7 +211,22 @@ public class ClientRSocketConnector extends AbstractRSocketConnector {
this.rsocketRequester.rsocketClient().source().subscribe();
}
public RSocketRequester getRSocketRequester() {
/**
* Return the {@link Mono} for the {@link RSocketRequester}.
* @return the {@link Mono} for the {@link RSocketRequester}.
* @deprecated since 5.4 in favor of {@link #getRequester()}
*/
@Deprecated
public Mono<RSocketRequester> getRSocketRequester() {
return Mono.just(getRequester());
}
/**
* Return the {@link RSocketRequester} this connector is built on.
* @return the {@link RSocketRequester} this connector is built on.
* @since 5.4
*/
public RSocketRequester getRequester() {
return this.rsocketRequester;
}

View File

@@ -48,7 +48,7 @@ public class RSocketOutboundGatewaySpec extends MessageHandlerSpec<RSocketOutbou
/**
* Configure a {@link ClientRSocketConnector} for client side requests based on the connection
* provided by the {@link ClientRSocketConnector#getRSocketRequester()}.
* provided by the {@link ClientRSocketConnector#getRequester()}.
* @param clientRSocketConnector the {@link ClientRSocketConnector} to use.
* @return the spec
* @see RSocketOutboundGateway#setClientRSocketConnector(ClientRSocketConnector)

View File

@@ -120,7 +120,7 @@ public class RSocketOutboundGateway extends AbstractReplyProducingMessageHandler
/**
* Configure a {@link ClientRSocketConnector} for client side requests based on the connection
* provided by the {@link ClientRSocketConnector#getRSocketRequester()}.
* provided by the {@link ClientRSocketConnector#getRequester()}.
* In case of server side, an {@link RSocketRequester} must be provided in the
* {@link RSocketRequesterMethodArgumentResolver#RSOCKET_REQUESTER_HEADER} header of request message.
* @param clientRSocketConnector the {@link ClientRSocketConnector} to use.
@@ -207,7 +207,7 @@ public class RSocketOutboundGateway extends AbstractReplyProducingMessageHandler
super.doInit();
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
if (this.clientRSocketConnector != null) {
this.rsocketRequester = this.clientRSocketConnector.getRSocketRequester();
this.rsocketRequester = this.clientRSocketConnector.getRequester();
}
}

View File

@@ -96,8 +96,7 @@ public class RSocketInboundGatewayIntegrationTests {
this.serverRsocketRequester = serverConfig.clientRequester.asMono().block(Duration.ofSeconds(10));
}
else {
this.clientRsocketRequester =
this.clientRSocketConnector.getRSocketRequester();
this.clientRsocketRequester = this.clientRSocketConnector.getRequester();
}
}