com.linecorp.armeria.common.HttpResponse.subscribe()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.linecorp.armeria.common.HttpResponse.subscribe()方法的一些代码示例,展示了HttpResponse.subscribe()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.subscribe()方法的具体详情如下:
包路径:com.linecorp.armeria.common.HttpResponse
类名称:HttpResponse
方法名:subscribe

HttpResponse.subscribe介绍

暂无

代码示例

代码示例来源:origin: line/armeria

ArmeriaHttpClientResponseSubscriber(HttpResponse httpResponse) {
  httpResponse.completionFuture().whenComplete(this);
  httpResponse.subscribe(this, eventLoop);
}

代码示例来源:origin: line/armeria

/**
 * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and
 * the trailing headers of the response are received fully.
 */
default CompletableFuture<AggregatedHttpMessage> aggregate() {
  final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>();
  final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, null);
  completionFuture().handle(aggregator);
  subscribe(aggregator);
  return future;
}

代码示例来源:origin: line/armeria

/**
 * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and
 * the trailing headers of the response are received fully. {@link AggregatedHttpMessage#content()} will
 * return a pooled object, and the caller must ensure to release it. If you don't know what this means,
 * use {@link #aggregate()}.
 */
default CompletableFuture<AggregatedHttpMessage> aggregateWithPooledObjects(ByteBufAllocator alloc) {
  requireNonNull(alloc, "alloc");
  final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>();
  final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, alloc);
  completionFuture().handle(aggregator);
  subscribe(aggregator, true);
  return future;
}

代码示例来源:origin: line/armeria

@Override
public void enqueue(Callback callback) {
  createRequest();
  httpResponse.subscribe(callFactory.subscriberFactory.create(this, callback, request));
}

代码示例来源:origin: line/armeria

/**
   * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and
   * the trailing headers of the request is received fully. {@link AggregatedHttpMessage#content()} will
   * return a pooled object, and the caller must ensure to release it. If you don't know what this means,
   * use {@link #aggregate()}.
   */
  default CompletableFuture<AggregatedHttpMessage> aggregateWithPooledObjects(
      EventExecutor executor, ByteBufAllocator alloc) {
    requireNonNull(executor, "executor");
    requireNonNull(alloc, "alloc");
    final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>();
    final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, alloc);
    completionFuture().handleAsync(aggregator, executor);
    subscribe(aggregator, executor, true);
    return future;
  }
}

代码示例来源:origin: line/armeria

/**
 * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and
 * the trailing headers of the response are received fully.
 */
default CompletableFuture<AggregatedHttpMessage> aggregate(EventExecutor executor) {
  final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>();
  final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, null);
  completionFuture().handleAsync(aggregator, executor);
  subscribe(aggregator, executor);
  return future;
}

代码示例来源:origin: line/armeria

AtomicReference<Throwable> error = new AtomicReference<>();
client.get("/trailers").subscribe(new Subscriber<HttpObject>() {
  @Override
  public void onSubscribe(Subscription s) {

代码示例来源:origin: line/armeria

AtomicReference<Throwable> error = new AtomicReference<>();
client.get("/trailers-only").subscribe(new Subscriber<HttpObject>() {
  @Override
  public void onSubscribe(Subscription s) {

代码示例来源:origin: line/armeria

final HttpClient client = HttpClient.of(rule.uri("/streaming"));
final AtomicBoolean isFinished = new AtomicBoolean();
client.get("/json").subscribe(new DefaultSubscriber<HttpObject>() {
  final ImmutableList.Builder<HttpObject> received = new Builder<>();

代码示例来源:origin: line/armeria

new HttpResponseSubscriber(ctx, responseEncoder, reqCtx, req, accessLogWriter);
reqCtx.setRequestTimeoutChangeListener(resSubscriber);
res.subscribe(resSubscriber, eventLoop, true);

代码示例来源:origin: line/armeria

@Override
public void start(Listener<O> responseListener, Metadata unused) {
  requireNonNull(responseListener, "responseListener");
  final Compressor compressor;
  if (callOptions.getCompressor() != null) {
    compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor());
    if (compressor == null) {
      responseListener.onClose(
          Status.INTERNAL.withDescription(
              "Unable to find compressor by name " + callOptions.getCompressor()),
          EMPTY_METADATA);
      return;
    }
  } else {
    compressor = Identity.NONE;
  }
  messageFramer.setCompressor(compressor);
  prepareHeaders(req.headers(), compressor);
  listener = responseListener;
  final HttpResponse res;
  try (SafeCloseable ignored = ctx.push()) {
    res = httpClient.execute(ctx, req);
  } catch (Exception e) {
    close(Status.fromThrowable(e));
    return;
  }
  res.subscribe(responseReader, ctx.eventLoop(), true);
  res.completionFuture().handleAsync(responseReader, ctx.eventLoop());
}

代码示例来源:origin: com.linecorp.armeria/armeria-grpc

@Override
public void start(Listener<O> responseListener, Metadata unused) {
  requireNonNull(responseListener, "responseListener");
  final Compressor compressor;
  if (callOptions.getCompressor() != null) {
    compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor());
    if (compressor == null) {
      responseListener.onClose(
          Status.INTERNAL.withDescription(
              "Unable to find compressor by name " + callOptions.getCompressor()),
          EMPTY_METADATA);
      return;
    }
  } else {
    compressor = Identity.NONE;
  }
  messageFramer.setCompressor(compressor);
  prepareHeaders(req.headers(), compressor);
  listener = responseListener;
  final HttpResponse res;
  try (SafeCloseable ignored = ctx.push()) {
    res = httpClient.execute(ctx, req);
  } catch (Exception e) {
    close(Status.fromThrowable(e));
    return;
  }
  res.subscribe(responseReader, ctx.eventLoop(), true);
  res.completionFuture().handleAsync(responseReader, ctx.eventLoop());
}

相关文章