|
| 1 | +package io.rsocket; |
| 2 | + |
| 3 | +import org.reactivestreams.Publisher; |
| 4 | +import reactor.core.Disposable; |
| 5 | +import reactor.core.publisher.Flux; |
| 6 | +import reactor.core.publisher.Mono; |
| 7 | + |
| 8 | +/** |
| 9 | + * A client-side interface to simplify interactions with the {@link |
| 10 | + * io.rsocket.core.RSocketConnector} |
| 11 | + * |
| 12 | + * @since 1.0.1 |
| 13 | + */ |
| 14 | +public interface RSocketClient extends Disposable { |
| 15 | + |
| 16 | + /** |
| 17 | + * Provides access to the source {@link RSocket} used by this {@link RSocketClient} |
| 18 | + * |
| 19 | + * @return returns a {@link Mono} which returns the source {@link RSocket} |
| 20 | + */ |
| 21 | + Mono<RSocket> source(); |
| 22 | + |
| 23 | + /** |
| 24 | + * Fire and Forget interaction model of {@link RSocketClient}. |
| 25 | + * |
| 26 | + * @param payloadMono Request payload as {@link Mono}. |
| 27 | + * @return {@code Publisher} that completes when the passed {@code payload} is successfully |
| 28 | + * handled, otherwise errors. |
| 29 | + */ |
| 30 | + Mono<Void> fireAndForget(Mono<Payload> payloadMono); |
| 31 | + |
| 32 | + /** |
| 33 | + * Request-Response interaction model of {@link RSocketClient}. |
| 34 | + * |
| 35 | + * @param payloadMono Request payload as {@link Mono}. |
| 36 | + * @return {@code Publisher} containing at most a single {@code Payload} representing the |
| 37 | + * response. |
| 38 | + */ |
| 39 | + Mono<Payload> requestResponse(Mono<Payload> payloadMono); |
| 40 | + |
| 41 | + /** |
| 42 | + * Request-Stream interaction model of {@link RSocketClient}. |
| 43 | + * |
| 44 | + * @param payloadMono Request payload as {@link Mono}. |
| 45 | + * @return {@code Publisher} containing the stream of {@code Payload}s representing the response. |
| 46 | + */ |
| 47 | + Flux<Payload> requestStream(Mono<Payload> payloadMono); |
| 48 | + |
| 49 | + /** |
| 50 | + * Request-Channel interaction model of {@link RSocketClient}. |
| 51 | + * |
| 52 | + * @param payloads Stream of request payloads. |
| 53 | + * @return Stream of response payloads. |
| 54 | + */ |
| 55 | + Flux<Payload> requestChannel(Publisher<Payload> payloads); |
| 56 | + |
| 57 | + /** |
| 58 | + * Metadata-Push interaction model of {@link RSocketClient}. |
| 59 | + * |
| 60 | + * @param payloadMono Request payload as {@link Mono}. |
| 61 | + * @return {@code Publisher} that completes when the passed {@code payload} is successfully |
| 62 | + * handled, otherwise errors. |
| 63 | + */ |
| 64 | + Mono<Void> metadataPush(Mono<Payload> payloadMono); |
| 65 | +} |
0 commit comments