public class LoadbalanceRSocketClient extends Object implements RSocketClient
RSocketClient backed by a pool of RSocket instances and
using a LoadbalanceStrategy to select the RSocket to use for a given request.| Modifier and Type | Class and Description |
|---|---|
static class |
LoadbalanceRSocketClient.Builder
Builder for creating an
LoadbalanceRSocketClient. |
Disposable.Composite, Disposable.Swap| Modifier and Type | Method and Description |
|---|---|
static LoadbalanceRSocketClient.Builder |
builder(org.reactivestreams.Publisher<List<LoadbalanceTarget>> targetPublisher)
Return a builder for a
LoadbalanceRSocketClient. |
boolean |
connect()
Connect to the remote rsocket endpoint, if not yet connected.
|
static LoadbalanceRSocketClient |
create(RSocketConnector connector,
org.reactivestreams.Publisher<List<LoadbalanceTarget>> targetPublisher)
Shortcut to create an
LoadbalanceRSocketClient with round-robin load balancing. |
void |
dispose() |
Mono<Void> |
fireAndForget(Mono<Payload> payloadMono)
Perform a Fire-and-Forget interaction via
RSocket.fireAndForget(Payload). |
Mono<Void> |
metadataPush(Mono<Payload> payloadMono)
Perform a Metadata Push via
RSocket.metadataPush(Payload). |
Mono<Void> |
onClose()
Returns a
Mono that terminates when the instance is terminated by any reason. |
Flux<Payload> |
requestChannel(org.reactivestreams.Publisher<Payload> payloads)
Perform a Request-Channel interaction via
RSocket.requestChannel(Publisher). |
Mono<Payload> |
requestResponse(Mono<Payload> payloadMono)
Perform a Request-Response interaction via
RSocket.requestResponse(Payload). |
Flux<Payload> |
requestStream(Mono<Payload> payloadMono)
Perform a Request-Stream interaction via
RSocket.requestStream(Payload). |
Mono<RSocket> |
source()
Return
Mono that selects an RSocket from the underlying pool. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfrom, fromisDisposedpublic Mono<Void> onClose()
CloseableMono 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
Subscriber.onError(Throwable). Otherwise, Subscriber.onComplete() will be called.onClose in interface CloseableonClose in interface RSocketClientMono 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.public boolean connect()
RSocketClientRSocketClient#source().subscribe().connect in interface RSocketClienttrue if an attempt to connect was triggered or if already connected, or false if the client is terminated.public Mono<RSocket> source()
Mono that selects an RSocket from the underlying pool.source in interface RSocketClientpublic Mono<Void> fireAndForget(Mono<Payload> payloadMono)
RSocketClientRSocket.fireAndForget(Payload). Allows
multiple subscriptions and performs a request per subscriber.fireAndForget in interface RSocketClientpublic Mono<Payload> requestResponse(Mono<Payload> payloadMono)
RSocketClientRSocket.requestResponse(Payload). Allows
multiple subscriptions and performs a request per subscriber.requestResponse in interface RSocketClientpublic Flux<Payload> requestStream(Mono<Payload> payloadMono)
RSocketClientRSocket.requestStream(Payload). Allows
multiple subscriptions and performs a request per subscriber.requestStream in interface RSocketClientpublic Flux<Payload> requestChannel(org.reactivestreams.Publisher<Payload> payloads)
RSocketClientRSocket.requestChannel(Publisher). Allows
multiple subscriptions and performs a request per subscriber.requestChannel in interface RSocketClientpublic Mono<Void> metadataPush(Mono<Payload> payloadMono)
RSocketClientRSocket.metadataPush(Payload). Allows multiple
subscriptions and performs a request per subscriber.metadataPush in interface RSocketClientpublic void dispose()
dispose in interface Disposablepublic static LoadbalanceRSocketClient create(RSocketConnector connector, org.reactivestreams.Publisher<List<LoadbalanceTarget>> targetPublisher)
LoadbalanceRSocketClient with round-robin load balancing.
Effectively a shortcut for:
LoadbalanceRSocketClient.builder(targetPublisher)
.connector(RSocketConnector.create())
.build();
connector - a "template" for connecting to load balance targetstargetPublisher - refreshes the list of load balance targets periodicallypublic static LoadbalanceRSocketClient.Builder builder(org.reactivestreams.Publisher<List<LoadbalanceTarget>> targetPublisher)
LoadbalanceRSocketClient.targetPublisher - refreshes the list of load balance targets periodically