Interface RSocketRequester
public interface RSocketRequester
A thin wrapper around a sendingRSocket
with a fluent API accepting and returning higher level Objects for input and for output, along with methods to prepare routing and other metadata.- Since:
- 5.2
- Author:
- Rossen Stoyanchev, Brian Clozel
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RSocketRequester.Builder
Builder to create a requester by connecting to a server.static interface
RSocketRequester.MetadataSpec<S extends RSocketRequester.MetadataSpec<S>>
Spec for providing additional composite metadata entries.static interface
RSocketRequester.RequestSpec
Spec to declare the input for an RSocket request.static interface
RSocketRequester.RetrieveSpec
Spec to declare the expected output for an RSocket request.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static RSocketRequester.Builder
builder()
Obtain a builder to create a clientRSocketRequester
by connecting to an RSocket server.MimeType
dataMimeType()
Return the dataMimeType
selected for the underlying RSocket at connection time.RSocketRequester.RequestSpec
metadata(Object metadata, MimeType mimeType)
Begin to specify a new request with the given metadata value, which can be a concrete value or any producer of a single value that can be adapted to aPublisher
viaReactiveAdapterRegistry
.MimeType
metadataMimeType()
Return the metadataMimeType
selected for the underlying RSocket at connection time.RSocketRequester.RequestSpec
route(String route, Object... routeVars)
Begin to specify a new request with the given route to a remote handler.io.rsocket.RSocket
rsocket()
Return the underlying sending RSocket.static RSocketRequester
wrap(io.rsocket.RSocket rsocket, MimeType dataMimeType, MimeType metadataMimeType, RSocketStrategies strategies)
Wrap an existingRSocket
.
Method Detail
rsocket
io.rsocket.RSocket rsocket()
Return the underlying sending RSocket.
dataMimeType
MimeType dataMimeType()
Return the dataMimeType
selected for the underlying RSocket at connection time. On the client side this is configured viaRSocketRequester.Builder.dataMimeType(MimeType)
while on the server side it's obtained from theConnectionSetupPayload
.
metadataMimeType
MimeType metadataMimeType()
Return the metadataMimeType
selected for the underlying RSocket at connection time. On the client side this is configured viaRSocketRequester.Builder.metadataMimeType(MimeType)
while on the server side it's obtained from theConnectionSetupPayload
.
route
RSocketRequester.RequestSpec route(String route, Object... routeVars)
Begin to specify a new request with the given route to a remote handler.The route can be a template with placeholders, e.g.
"flight.{code}"
in which case the supplied route variables are formatted viatoString()
and expanded into the template. If a formatted variable contains a "." it is replaced with the escape sequence "%2E" to avoid treating it as separator by the responder .If the connection is set to use composite metadata, the route is encoded as
"message/x.rsocket.routing.v0"
. Otherwise the route is encoded according to the mime type for the connection.- Parameters:
route
- the route expressing a remote handler mappingrouteVars
- variables to be expanded into the route template- Returns:
- a spec for further defining and executing the request
metadata
RSocketRequester.RequestSpec metadata(Object metadata, @Nullable MimeType mimeType)
Begin to specify a new request with the given metadata value, which can be a concrete value or any producer of a single value that can be adapted to aPublisher
viaReactiveAdapterRegistry
.- Parameters:
metadata
- the metadata value to encodemimeType
- the mime type that describes the metadata; This is required for connection using composite metadata. Otherwise the value is encoded according to the mime type for the connection and this argument may be left asnull
.
builder
static RSocketRequester.Builder builder()
Obtain a builder to create a clientRSocketRequester
by connecting to an RSocket server.
wrap
static RSocketRequester wrap(io.rsocket.RSocket rsocket, MimeType dataMimeType, MimeType metadataMimeType, RSocketStrategies strategies)
Wrap an existingRSocket
. Typically used in client or server responders to wrap theRSocket
for the remote side.