use of io.vertx.core.http.HttpClientRequest in project parser-excel-elasticsearch by codingchili.
the class ElasticWriter method post.
private HttpClientRequest post(String path) {
HttpClientRequest client = vertx.createHttpClient().post(getOptions(path));
addHeaders(client);
return client;
}
use of io.vertx.core.http.HttpClientRequest in project parser-excel-elasticsearch by codingchili.
the class ElasticWriter method delete.
private HttpClientRequest delete(String path) {
HttpClientRequest request = vertx.createHttpClient().delete(getOptions(path));
addHeaders(request);
return request;
}
use of io.vertx.core.http.HttpClientRequest in project vertx-micrometer-metrics by vert-x3.
the class PrometheusMetricsITest method shouldExposeEventBusMetrics.
@Test
public void shouldExposeEventBusMetrics(TestContext context) {
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true).setStartEmbeddedServer(true).setEmbeddedServerOptions(new HttpServerOptions().setPort(9090))).setEnabled(true)));
// Send something on the eventbus and wait til it's received
Async asyncEB = context.async();
vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
vertx.eventBus().publish("test-eb", "test message");
asyncEB.await(2000);
// Read metrics on HTTP endpoint for eventbus metrics
Async async = context.async();
HttpClientRequest req = vertx.createHttpClient().get(9090, "localhost", "/metrics").handler(res -> {
context.assertEquals(200, res.statusCode());
res.bodyHandler(body -> {
String str = body.toString();
context.verify(v -> assertThat(str).contains("vertx_eventbus_published_total{address=\"test-eb\",side=\"local\",} 1.0", "vertx_eventbus_received_total{address=\"test-eb\",side=\"local\",} 1.0", "vertx_eventbus_handlers{address=\"test-eb\",} 1.0", "vertx_eventbus_delivered_total{address=\"test-eb\",side=\"local\",} 1.0", "vertx_eventbus_processingTime_seconds_count{address=\"test-eb\",} 1.0"));
async.complete();
});
});
req.end();
async.awaitSuccess(10000);
}
use of io.vertx.core.http.HttpClientRequest in project vertx-micrometer-metrics by vert-x3.
the class PrometheusMetricsITest method tryConnect.
private static void tryConnect(Vertx vertx, TestContext context, int port, String host, String requestURI, Consumer<String> bodyReader, int attempt) {
HttpClientRequest req = vertx.createHttpClient().get(port, host, requestURI).handler(res -> {
context.assertEquals(200, res.statusCode());
res.bodyHandler(body -> bodyReader.accept(body.toString()));
}).exceptionHandler(e -> {
if (attempt < 10) {
System.out.println(e);
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
System.out.println("retrying...");
tryConnect(vertx, context, port, host, requestURI, bodyReader, attempt + 1);
} else {
System.out.println("aborting");
}
});
req.end();
}
use of io.vertx.core.http.HttpClientRequest in project okapi by folio-org.
the class ProxyService method proxyHeaders.
private void proxyHeaders(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) {
proxyResponseImmediate(pc, res, mi);
if (bcontent == null) {
stream.resume();
}
} else if (it.hasNext()) {
relayToRequest(res, pc, mi);
makeTraceHeader(mi, res.statusCode(), pc);
res.endHandler(x -> proxyR(it, pc, stream, bcontent));
} else {
relayToResponse(ctx.response(), res);
makeTraceHeader(mi, res.statusCode(), pc);
if (bcontent == null) {
stream.handler(data -> {
ctx.response().write(data);
pc.trace("ProxyHeaders request chunk '" + data.toString() + "'");
});
stream.endHandler(v -> {
ctx.response().end();
pc.trace("ProxyHeaders request end");
});
stream.exceptionHandler(e -> pc.warn("proxyHeaders: content exception ", e));
stream.resume();
} else {
pc.trace("ProxyHeaders request buf '" + bcontent + "'");
ctx.response().end(bcontent);
}
}
});
cReq.exceptionHandler(e -> {
pc.warn("proxyHeaders failure: " + mi.getUrl() + ": ", e);
pc.responseText(500, "proxyHeaders failure: " + mi.getModuleDescriptor().getId() + " " + mi.getUrl() + ": " + e + " " + e.getMessage());
});
cReq.headers().setAll(ctx.request().headers());
cReq.headers().remove("Content-Length");
cReq.end();
log(pc, cReq);
}
Aggregations