use of io.knotx.server.configuration.RoutingEntry in project knotx by Cognifide.
the class KnotxEngineHandler method handleRoute.
private void handleRoute(final RoutingContext context, final String address, final Map<String, RoutingEntry> routing) {
KnotContext knotContext = context.get(KnotContext.KEY);
proxies.computeIfAbsent(address, adr -> KnotProxy.createProxyWithOptions(vertx, adr, configuration.getDeliveryOptions())).rxProcess(knotContext).doOnSuccess(ctx -> context.put(KnotContext.KEY, ctx)).subscribe(ctx -> OptionalAction.of(Optional.ofNullable(ctx.getTransition())).ifPresent(on -> {
RoutingEntry entry = routing.get(on);
if (entry != null) {
handleRoute(context, entry.address(), entry.onTransition());
} else {
LOGGER.debug("Received transition '{}' from '{}'. No further routing available for the transition. Go to the response generation.", on, address);
// last knot can return default transition
context.put(KnotContext.KEY, ctx);
context.next();
}
}).ifNotPresent(() -> {
LOGGER.debug("Request processing finished by {} Knot. Go to the response generation", address);
context.put(KnotContext.KEY, ctx);
context.next();
}), error -> {
LOGGER.error("Error happened while communicating with {} engine", error, address);
context.fail(error);
});
}
Aggregations