Skip to content

Commit 2fa2120

Browse files
committed
provides RSocketClient interface
Signed-off-by: Oleh Dokuka <[email protected]>
1 parent 951bf03 commit 2fa2120

File tree

5 files changed

+1337
-106
lines changed

5 files changed

+1337
-106
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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}. This interface represents logical communication over {@link
11+
* RSocket}, hiding the complexity of {@code Mono<RSocket>} resolution. Also, in opposite to {@link
12+
* RSocket} , {@link RSocketClient} supports multi-subscription on the same {@link Publisher} from
13+
* the interaction in the way of accepting input as {@link Publisher} like {@link Mono} or {@link
14+
* Flux} Despite, {@link RSocket} interface, {@link RSocketClient} does not coupled with a single
15+
* connection, hence disposal of the {@link #source()} {@link RSocket} will affect the {@link
16+
* RSocketClient} it selves. In such a case, a new request will cause automatic reconnection if
17+
* necessary.
18+
*
19+
* @since 1.0.1
20+
*/
21+
public interface RSocketClient extends Disposable {
22+
23+
/**
24+
* Provides access to the source {@link RSocket} used by this {@link RSocketClient}
25+
*
26+
* @return returns a {@link Mono} which returns the source {@link RSocket}
27+
*/
28+
Mono<RSocket> source();
29+
30+
/**
31+
* Fire and Forget interaction model of {@link RSocketClient}.
32+
*
33+
* @param payloadMono Request payload as {@link Mono}.
34+
* @return {@code Publisher} that completes when the passed {@code payload} is successfully
35+
* handled, otherwise errors.
36+
*/
37+
Mono<Void> fireAndForget(Mono<Payload> payloadMono);
38+
39+
/**
40+
* Request-Response interaction model of {@link RSocketClient}.
41+
*
42+
* @param payloadMono Request payload as {@link Mono}.
43+
* @return {@code Publisher} containing at most a single {@code Payload} representing the
44+
* response.
45+
*/
46+
Mono<Payload> requestResponse(Mono<Payload> payloadMono);
47+
48+
/**
49+
* Request-Stream interaction model of {@link RSocketClient}.
50+
*
51+
* @param payloadMono Request payload as {@link Mono}.
52+
* @return {@code Publisher} containing the stream of {@code Payload}s representing the response.
53+
*/
54+
Flux<Payload> requestStream(Mono<Payload> payloadMono);
55+
56+
/**
57+
* Request-Channel interaction model of {@link RSocketClient}.
58+
*
59+
* @param payloads Stream of request payloads.
60+
* @return Stream of response payloads.
61+
*/
62+
Flux<Payload> requestChannel(Publisher<Payload> payloads);
63+
64+
/**
65+
* Metadata-Push interaction model of {@link RSocketClient}.
66+
*
67+
* @param payloadMono Request payload as {@link Mono}.
68+
* @return {@code Publisher} that completes when the passed {@code payload} is successfully
69+
* handled, otherwise errors.
70+
*/
71+
Mono<Void> metadataPush(Mono<Payload> payloadMono);
72+
}

0 commit comments

Comments
 (0)