use of com.linecorp.armeria.common.HttpRequestWriter in project zipkin by openzipkin.
the class HttpCall method sendRequest.
CompletableFuture<AggregatedHttpResponse> sendRequest() {
final HttpResponse response;
try (SafeCloseable ignored = Clients.withContextCustomizer(ctx -> ctx.logBuilder().name(name))) {
HttpRequestWriter httpRequest = HttpRequest.streaming(request.headers());
response = httpClient.execute(httpRequest);
request.writeBody(httpRequest::tryWrite);
httpRequest.close();
}
CompletableFuture<AggregatedHttpResponse> responseFuture = RequestContext.mapCurrent(ctx -> response.aggregateWithPooledObjects(ctx.eventLoop(), ctx.alloc()), // This should never be used in practice since the module runs in an Armeria server.
response::aggregate);
responseFuture = responseFuture.exceptionally(t -> {
if (t instanceof UnprocessedRequestException) {
Throwable cause = t.getCause();
// Go ahead and reduce the output in logs since this is usually a configuration or
// infrastructure issue and the Armeria stack trace won't help debugging that.
Exceptions.clearTrace(cause);
String message = cause.getMessage();
if (message == null)
message = cause.getClass().getSimpleName();
throw new RejectedExecutionException(message, cause);
} else {
Exceptions.throwUnsafely(t);
}
return null;
});
this.responseFuture = responseFuture;
return responseFuture;
}
use of com.linecorp.armeria.common.HttpRequestWriter in project zipkin by openzipkin.
the class BulkRequestBenchmarks method buildAndWriteRequest_singleSpan.
@Benchmark
public HttpRequest buildAndWriteRequest_singleSpan() {
BulkCallBuilder builder = new BulkCallBuilder(es, V6_0, "index-span");
builder.index(spanIndex, "span", CLIENT_SPAN, BulkIndexWriter.SPAN);
HttpCall.RequestSupplier supplier = builder.build().request;
HttpRequestWriter request = HttpRequest.streaming(supplier.headers());
supplier.writeBody(request::tryWrite);
return request;
}
use of com.linecorp.armeria.common.HttpRequestWriter in project zipkin by openzipkin.
the class BulkRequestBenchmarks method buildAndWriteRequest_tenSpans.
@Benchmark
public HttpRequest buildAndWriteRequest_tenSpans() {
BulkCallBuilder builder = new BulkCallBuilder(es, V6_0, "index-span");
for (int i = 0; i < 10; i++) {
builder.index(spanIndex, "span", CLIENT_SPAN, BulkIndexWriter.SPAN);
}
HttpCall.RequestSupplier supplier = builder.build().request;
HttpRequestWriter request = HttpRequest.streaming(supplier.headers());
supplier.writeBody(request::tryWrite);
return request;
}
Aggregations