Add debug timeout handler, change default log level (for now)

This commit is contained in:
Colin McDonald 2016-07-03 16:32:56 -04:00
parent fa5aee848a
commit 85b98b4a1d
2 changed files with 14 additions and 3 deletions

View File

@ -30,7 +30,6 @@ import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.ext.web.handler.LoggerFormat;
import io.vertx.ext.web.handler.LoggerHandler;
import io.vertx.ext.web.handler.TimeoutHandler;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.frozenorb.apiv3.handler.ActorAttributeHandler;
@ -104,7 +103,6 @@ import java.time.Instant;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Slf4j
public final class APIv3 extends AbstractVerticle {
@ -245,7 +243,19 @@ public final class APIv3 extends AbstractVerticle {
Router http = Router.router(vertx);
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().handler(new ActorAttributeHandler());
http.route().handler(new MetricsHandler());

View File

@ -5,6 +5,7 @@ import io.vertx.core.Vertx;
final class Main {
public static void main(String[] args) {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
Vertx.vertx().deployVerticle(new APIv3());