public class ReadStreamSubscriber<R,J>
extends rx.Subscriber<R>
implements io.vertx.core.streams.ReadStream<J>
Subscriber
that turns an Observable
into a ReadStream
.
The stream implements the pause()
and resume()
operation by maintaining
a buffer of BUFFER_SIZE
elements between the Observable
and the ReadStream
.
When the subscriber is created it requests 0
elements to activate the subscriber's back-pressure.
Setting the handler initially on the ReadStream
triggers a request of BUFFER_SIZE
elements.
When the item buffer is half empty, new elements are requested to fill the buffer back to BUFFER_SIZE
elements.
The #endHandler(Handler
is called when the Observable
is completed or has failed and
no pending elements, emitted before the completion or failure, are still in the buffer, i.e the handler
is not called when the stream is paused.
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE |
Constructor and Description |
---|
ReadStreamSubscriber(Function<R,J> adapter) |
Modifier and Type | Method and Description |
---|---|
static <R,J> io.vertx.core.streams.ReadStream<J> |
asReadStream(rx.Observable<R> observable,
Function<R,J> adapter) |
io.vertx.core.streams.ReadStream<J> |
endHandler(io.vertx.core.Handler<Void> handler) |
io.vertx.core.streams.ReadStream<J> |
exceptionHandler(io.vertx.core.Handler<Throwable> handler) |
io.vertx.core.streams.ReadStream<J> |
fetch(long amount) |
io.vertx.core.streams.ReadStream<J> |
handler(io.vertx.core.Handler<J> handler) |
void |
onCompleted() |
void |
onError(Throwable e) |
void |
onNext(R item) |
io.vertx.core.streams.ReadStream<J> |
pause() |
io.vertx.core.streams.ReadStream<J> |
resume() |
add, isUnsubscribed, onStart, request, setProducer, unsubscribe
public static final int BUFFER_SIZE
public static <R,J> io.vertx.core.streams.ReadStream<J> asReadStream(rx.Observable<R> observable, Function<R,J> adapter)
public io.vertx.core.streams.ReadStream<J> handler(io.vertx.core.Handler<J> handler)
handler
in interface io.vertx.core.streams.ReadStream<J>
public io.vertx.core.streams.ReadStream<J> fetch(long amount)
fetch
in interface io.vertx.core.streams.ReadStream<J>
public io.vertx.core.streams.ReadStream<J> pause()
pause
in interface io.vertx.core.streams.ReadStream<J>
public io.vertx.core.streams.ReadStream<J> resume()
resume
in interface io.vertx.core.streams.ReadStream<J>
public io.vertx.core.streams.ReadStream<J> endHandler(io.vertx.core.Handler<Void> handler)
endHandler
in interface io.vertx.core.streams.ReadStream<J>
public io.vertx.core.streams.ReadStream<J> exceptionHandler(io.vertx.core.Handler<Throwable> handler)
exceptionHandler
in interface io.vertx.core.streams.ReadStream<J>
exceptionHandler
in interface io.vertx.core.streams.StreamBase
public void onCompleted()
onCompleted
in interface rx.Observer<R>
Copyright © 2019 Eclipse. All rights reserved.