Add debug timeout handler, change default log level (for now)
This commit is contained in:
parent
fa5aee848a
commit
85b98b4a1d
@ -30,7 +30,6 @@ import io.vertx.ext.web.RoutingContext;
|
|||||||
import io.vertx.ext.web.handler.BodyHandler;
|
import io.vertx.ext.web.handler.BodyHandler;
|
||||||
import io.vertx.ext.web.handler.LoggerFormat;
|
import io.vertx.ext.web.handler.LoggerFormat;
|
||||||
import io.vertx.ext.web.handler.LoggerHandler;
|
import io.vertx.ext.web.handler.LoggerHandler;
|
||||||
import io.vertx.ext.web.handler.TimeoutHandler;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.frozenorb.apiv3.handler.ActorAttributeHandler;
|
import net.frozenorb.apiv3.handler.ActorAttributeHandler;
|
||||||
@ -104,7 +103,6 @@ import java.time.Instant;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class APIv3 extends AbstractVerticle {
|
public final class APIv3 extends AbstractVerticle {
|
||||||
@ -245,7 +243,19 @@ public final class APIv3 extends AbstractVerticle {
|
|||||||
Router http = Router.router(vertx);
|
Router http = Router.router(vertx);
|
||||||
|
|
||||||
http.route().handler(LoggerHandler.create(LoggerFormat.TINY));
|
http.route().handler(LoggerHandler.create(LoggerFormat.TINY));
|
||||||
http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(7)));
|
//http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(5)));
|
||||||
|
http.route().handler((ctx) -> {
|
||||||
|
long tid = ctx.vertx().setTimer(5000, (t) -> {
|
||||||
|
log.error(ctx.getBodyAsString());
|
||||||
|
ctx.fail(503);
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.addBodyEndHandler((v) -> {
|
||||||
|
ctx.vertx().cancelTimer(tid);
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.next();
|
||||||
|
});
|
||||||
http.route().method(HttpMethod.PUT).method(HttpMethod.POST).method(HttpMethod.DELETE).handler(BodyHandler.create());
|
http.route().method(HttpMethod.PUT).method(HttpMethod.POST).method(HttpMethod.DELETE).handler(BodyHandler.create());
|
||||||
http.route().handler(new ActorAttributeHandler());
|
http.route().handler(new ActorAttributeHandler());
|
||||||
http.route().handler(new MetricsHandler());
|
http.route().handler(new MetricsHandler());
|
||||||
|
@ -5,6 +5,7 @@ import io.vertx.core.Vertx;
|
|||||||
final class Main {
|
final class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
|
||||||
System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
|
System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
|
||||||
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
|
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
|
||||||
Vertx.vertx().deployVerticle(new APIv3());
|
Vertx.vertx().deployVerticle(new APIv3());
|
||||||
|
Loading…
Reference in New Issue
Block a user