public interface Sender
Non-blocking sender. Reactive responses uses this class to send partial data in non-blocking
manner.
RxJava example:
Sender sender = ctx.getSender();
Flux.fromCallable(...)
.subscribe(new Subscriber () {
onSubscribe(Subscription s) {
this.subscription = s;
this.subscription.request(1);
}
onNext(Object next) {
sender.write(next, (ctx, cause) -> {
subscription.request(1);
});
}
onError(Throwable error) {
subscription.cancel();
}
onComplete() {
sender.close();
}
})
- Since:
- 2.0.0
- Author:
- edgar
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the sender.write
(byte[] data, Sender.Callback callback) Write a bytes chunk.default Sender
write
(String data, Sender.Callback callback) Write a string chunk.default Sender
write
(String data, Charset charset, Sender.Callback callback) Write a string chunk.
-
Method Details
-
write
Write a string chunk. Chunk is flushed immediately.- Parameters:
data
- String chunk.callback
- Callback.- Returns:
- This sender.
-
write
@NonNull default Sender write(@NonNull String data, @NonNull Charset charset, @NonNull Sender.Callback callback) Write a string chunk. Chunk is flushed immediately.- Parameters:
data
- String chunk.charset
- Charset.callback
- Callback.- Returns:
- This sender.
-
write
Write a bytes chunk. Chunk is flushed immediately.- Parameters:
data
- Bytes chunk.callback
- Callback.- Returns:
- This sender.
-
close
void close()Close the sender.
-