当前位置: 首页>>代码示例>>Java>>正文


Java ReadStream.endHandler方法代码示例

本文整理汇总了Java中io.vertx.core.streams.ReadStream.endHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ReadStream.endHandler方法的具体用法?Java ReadStream.endHandler怎么用?Java ReadStream.endHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.streams.ReadStream的用法示例。


在下文中一共展示了ReadStream.endHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: proxyRequestOnly

import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestOnly(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  if (bcontent != null) {
    proxyRequestHttpClient(it, pc, bcontent, mi);
  } else {
    final Buffer incoming = Buffer.buffer();
    stream.handler(data -> {
      incoming.appendBuffer(data);
      pc.trace("ProxyRequestOnly request chunk '"
        + data.toString() + "'");
    });
    stream.endHandler(v -> {
      pc.trace("ProxyRequestOnly request end");
      proxyRequestHttpClient(it, pc, incoming, mi);
    });
    stream.resume();
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:21,代码来源:ProxyService.java

示例2: proxyRequestResponse10

import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestResponse10(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  if (bcontent != null) {
    proxyRequestResponse(it, pc, null, bcontent, mi);
  } else {
    final Buffer incoming = Buffer.buffer();
    stream.handler(data -> {
      incoming.appendBuffer(data);
      pc.trace("ProxyRequestBlock request chunk '"
        + data.toString() + "'");
    });
    stream.endHandler(v -> {
      pc.trace("ProxyRequestBlock request end");
      proxyRequestResponse(it, pc, null, incoming, mi);
    });
    stream.resume();
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:21,代码来源:ProxyService.java

示例3: proxyInternal

import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyInternal(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  pc.debug("proxyInternal " + mi.getModuleDescriptor().getId());
  if (bcontent != null) {
    proxyInternalBuffer(it, pc, bcontent, mi);
  } else { // read the whole request into a buffer
    final Buffer incoming = Buffer.buffer();
    stream.handler(data -> {
      incoming.appendBuffer(data);
      pc.trace("proxyInternal request chunk '"
        + data.toString() + "'");
    });
    stream.endHandler(v -> {
      pc.trace("proxyInternal request end");
      proxyInternalBuffer(it, pc, incoming, mi);
    });
    stream.resume();
  }
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:22,代码来源:ProxyService.java

示例4: PressureHandler

import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
/**
 * Create a new back pressure handler.
 *
 * @param stream     stream to handle.
 * @param endpoint   endpoint name.
 * @param endHandler end handler to call.
 */
public PressureHandler(@NonNull ReadStream stream, String endpoint, Handler<Void> endHandler) {
    this.stream = stream;
    stream.endHandler(h -> {
        if (endHandler != null) endHandler.handle(null);
        nextPressure.clear();
        ended = true;
        log.info("Finish to read stream: " + endpoint);
    });
}
 
开发者ID:amannocci,项目名称:logbulk,代码行数:17,代码来源:PressureHandler.java

示例5: proxyRequestResponse

import io.vertx.core.streams.ReadStream; //导入方法依赖的package包/类
private void proxyRequestResponse(Iterator<ModuleInstance> it,
  ProxyContext pc, ReadStream<Buffer> stream, Buffer bcontent,
  ModuleInstance mi) {

  RoutingContext ctx = pc.getCtx();
  HttpClientRequest cReq = httpClient.requestAbs(ctx.request().method(),
    makeUrl(mi, ctx), res -> {
      if (res.statusCode() >= 200 && res.statusCode() < 300
      && res.getHeader(XOkapiHeaders.STOP) == null
      && it.hasNext()) {
        makeTraceHeader(mi, res.statusCode(), pc);
        relayToRequest(res, pc);
        res.pause();
        proxyR(it, pc, res, null);
      } else {
        relayToResponse(ctx.response(), res);
        makeTraceHeader(mi, res.statusCode(), pc);
        res.handler(data -> {
          ctx.response().write(data);
          pc.trace("ProxyRequestResponse response chunk '"
            + data.toString() + "'");
        });
        res.endHandler(v -> {
          pc.closeTimer();
          ctx.response().end();
          pc.trace("ProxyRequestResponse response end");
        });
        res.exceptionHandler(e
          -> pc.warn("proxyRequestResponse: res exception ", e));
      }
    });
  cReq.exceptionHandler(e -> {
    pc.warn("proxyRequestResponse failure: ", e);
    pc.responseText(500, "proxyRequestResponse failure: "
      + mi.getModuleDescriptor().getId() + " " + mi.getUrl() + ": "
      + e + " " + e.getMessage());
  });
  cReq.headers().setAll(ctx.request().headers());
  cReq.headers().remove("Content-Length");
  if (bcontent != null) {
    pc.trace("proxyRequestResponse request buf '" + bcontent + "'");
    cReq.end(bcontent);
  } else {
    cReq.setChunked(true);
    stream.handler(data -> {
      pc.trace("proxyRequestResponse request chunk '"
        + data.toString() + "'");
      cReq.write(data);
    });
    stream.endHandler(v -> {
      pc.trace("proxyRequestResponse request complete");
      cReq.end();
    });
    stream.exceptionHandler(e
      -> pc.warn("proxyRequestResponse: content exception ", e));
    stream.resume();
  }
  log(pc, cReq);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:60,代码来源:ProxyService.java


注:本文中的io.vertx.core.streams.ReadStream.endHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。