Java Code Examples for io.vertx.core.streams.Pump#pump()

The following examples show how to use io.vertx.core.streams.Pump#pump() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteFileSyncer.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private void pumpFileFromRequest(
        HttpClientResponse httpClientResponse, AsyncFile asyncFile, Promise<Void> promise) {

    logger.info("Trying to download file from {0}", downloadUrl);
    httpClientResponse.pause();
    final Pump pump = Pump.pump(httpClientResponse, asyncFile);
    pump.start();
    httpClientResponse.resume();

    final long idTimer = setTimeoutTimer(asyncFile, pump, promise);

    httpClientResponse.endHandler(responseEndResult -> handleResponseEnd(asyncFile, idTimer, promise));
}
 
Example 2
Source File: NativeExamples.java    From vertx-rx with Apache License 2.0 4 votes vote down vote up
public void toReadStream(io.vertx.rxjava.core.Vertx vertx, HttpServerResponse response) {
  Observable<Buffer> observable = getObservable();
  ReadStream<Buffer> readStream = RxHelper.toReadStream(observable);
  Pump pump = Pump.pump(readStream, response);
  pump.start();
}
 
Example 3
Source File: NativeExamples.java    From vertx-rx with Apache License 2.0 4 votes vote down vote up
public void toReadStream(HttpServerResponse response) {
  Flowable<Buffer> observable = getFlowable();
  ReadStream<Buffer> readStream = FlowableHelper.toReadStream(observable);
  Pump pump = Pump.pump(readStream, response);
  pump.start();
}
 
Example 4
Source File: ReactiveStreamsExamples.java    From vertx-reactive-streams with Apache License 2.0 3 votes vote down vote up
public void example1(HttpServerResponse response, Publisher<Buffer> otherPublisher) {

    ReactiveReadStream<Buffer> rrs = ReactiveReadStream.readStream();

    // Subscribe the read stream to the publisher
    otherPublisher.subscribe(rrs);

    // Pump from the read stream to the http response
    Pump pump = Pump.pump(rrs, response);

    pump.start();

  }
 
Example 5
Source File: ReactiveStreamsExamples.java    From vertx-reactive-streams with Apache License 2.0 3 votes vote down vote up
public void example2(Vertx vertx, HttpServerRequest request, Subscriber<Buffer> otherSubscriber) {

    ReactiveWriteStream<Buffer> rws = ReactiveWriteStream.writeStream(vertx);

    // Subscribe the other subscriber to the write stream
    rws.subscribe(otherSubscriber);

    // Pump the http request to the write stream
    Pump pump = Pump.pump(request, rws);

    pump.start();
  }