Top Description Methods
io.rsocket.core

public Interface RSocketClient

extends Closeable
Known Direct Implementers
io.rsocket.core.RSocketClientAdapter, io.rsocket.loadbalance.LoadbalanceRSocketClient, io.rsocket.core.DefaultRSocketClient
Imports
io.rsocket.Closeable, .Payload, .RSocket, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, sun.reflect.generics.reflectiveObjects.NotImplementedException

Contract for performing RSocket requests.

RSocketClient differs from RSocket in a number of ways:

The example below shows how to create an RSocketClient:

Mono<RSocket> source =
        RSocketConnector.create()
                .metadataMimeType("message/x.rsocket.composite-metadata.v0")
                .dataMimeType("application/cbor")
                .connect(TcpClientTransport.create("localhost", 7000));

RSocketClient client = RSocketClient.from(source);

The below configures retry logic to use when a shared RSocket connection is obtained:

Mono<RSocket> source =
        RSocketConnector.create()
                .metadataMimeType("message/x.rsocket.composite-metadata.v0")
                .dataMimeType("application/cbor")
                .reconnect(Retry.fixedDelay(3, Duration.ofSeconds(1)))
                .connect(TcpClientTransport.create("localhost", 7000));

RSocketClient client = RSocketClient.from(source);
Since
1.1
See Also
io.rsocket.loadbalance.LoadbalanceRSocketClient

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

true if an attempt to connect was triggered or if already connected, or false if the client is terminated.
connect
()

Connect to the remote rsocket endpoint, if not yet connected.

public Mono<Void>
fireAndForget(Mono<Payload> payloadMono)

Perform a Fire-and-Forget interaction via RSocket#fireAndForget(Payload).

public static RSocketClient

Returns:

the created client instance
from
(Mono<RSocket>
the source for connections, typically prepared via RSocketConnector.
source
)

Create an RSocketClient that obtains shared connections as needed, when requests are made, from the given Mono<RSocket> source.

public static RSocketClient

Returns:

the created client instance
from
(RSocket
the RSocket to perform requests with
rsocket
)

Adapt the given RSocket to use as RSocketClient.

public Mono<Void>
metadataPush(Mono<Payload> payloadMono)

Perform a Metadata Push via RSocket#metadataPush(Payload).

public default Mono<Void>
onClose()

Implements io.rsocket.Closeable.onClose.

Returns a Mono that terminates when the instance is terminated by any reason.
public Flux<Payload>
requestChannel(Publisher<Payload> payloads)

Perform a Request-Channel interaction via RSocket#requestChannel(Publisher).

public Mono<Payload>
requestResponse(Mono<Payload> payloadMono)

Perform a Request-Response interaction via RSocket#requestResponse(Payload).

public Flux<Payload>
requestStream(Mono<Payload> payloadMono)

Perform a Request-Stream interaction via RSocket#requestStream(Payload).

public Mono<RSocket>
source()

Return the underlying source used to obtain a shared RSocket connection.

Method Detail

connectback to summary
public default boolean connect()

Connect to the remote rsocket endpoint, if not yet connected. This method is a shortcut for RSocketClient#source().subscribe().

Returns:boolean

true if an attempt to connect was triggered or if already connected, or false if the client is terminated.

fireAndForgetback to summary
public Mono<Void> fireAndForget(Mono<Payload> payloadMono)

Perform a Fire-and-Forget interaction via RSocket#fireAndForget(Payload). Allows multiple subscriptions and performs a request per subscriber.

fromback to summary
public static RSocketClient from(Mono<RSocket> source)

Create an RSocketClient that obtains shared connections as needed, when requests are made, from the given Mono<RSocket> source.

Parameters
source:Mono<RSocket>

the source for connections, typically prepared via RSocketConnector.

Returns:RSocketClient

the created client instance

fromback to summary
public static RSocketClient from(RSocket rsocket)

Adapt the given RSocket to use as RSocketClient. This is useful to wrap the sending RSocket in a server.

Note

unlike an RSocketClient created via RSocketClient#from(Mono), the instance returned from this factory method can only perform requests for as long as the given RSocket remains "live".

Parameters
rsocket:RSocket

the RSocket to perform requests with

Returns:RSocketClient

the created client instance

metadataPushback to summary
public Mono<Void> metadataPush(Mono<Payload> payloadMono)

Perform a Metadata Push via RSocket#metadataPush(Payload). Allows multiple subscriptions and performs a request per subscriber.

onCloseback to summary
public default Mono<Void> onClose()

Implements io.rsocket.Closeable.onClose.

Doc from io.rsocket.Closeable.onClose.

Returns a Mono that terminates when the instance is terminated by any reason. Note, in case of error termination, the cause of error will be propagated as an error signal through org.reactivestreams.Subscriber#onError(Throwable). Otherwise, Subscriber#onComplete() will be called.

Returns:Mono<Void>

a Mono to track completion with success or error of the underlying resource. When the underlying resource is an `RSocket`, the Mono exposes stream 0 (i.e. connection level) errors.

requestChannelback to summary
public Flux<Payload> requestChannel(Publisher<Payload> payloads)

Perform a Request-Channel interaction via RSocket#requestChannel(Publisher). Allows multiple subscriptions and performs a request per subscriber.

requestResponseback to summary
public Mono<Payload> requestResponse(Mono<Payload> payloadMono)

Perform a Request-Response interaction via RSocket#requestResponse(Payload). Allows multiple subscriptions and performs a request per subscriber.

requestStreamback to summary
public Flux<Payload> requestStream(Mono<Payload> payloadMono)

Perform a Request-Stream interaction via RSocket#requestStream(Payload). Allows multiple subscriptions and performs a request per subscriber.

sourceback to summary
public Mono<RSocket> source()

Return the underlying source used to obtain a shared RSocket connection.