public void start(Config config) {
ApplicationState appState =
new ApplicationState(ApplicationConfig.fromConfig(proxyConfig, config));
Stream<ProxyRouteConfig> proxyRouteConfigs =
Arrays.stream(routeConfig.split(",")).map(it -> new ProxyRouteConfig(config.getConfig(it)));
ProxyClientFactory clientFactory = new ProxyClientFactory(appState);
RouteStates routeStates = new RouteStates(proxyRouteConfigs, appState, clientFactory);
application =
new ApplicationBootstrap(appState.config())
.addServer(
"main",
bs ->
bs.addToPipeline(
new SmartHttpPipeline() {
@Override
public ChannelHandler getApplicationRouter() {
return new PipelineRouter(routeStates.routeMap()) {
@Override
protected void channelRead0(ChannelHandlerContext ctx, Request msg) {
super.channelRead0(ctx, msg);
if (msg.endOfMessage()) {
requestCount.incrementAndGet();
}
}
};
}
}))
.build();
}