use of com.hotels.styx.client.healthcheck.OriginHealthStatusMonitor in project styx by ExpediaGroup.
the class BackendServicesRouter method onChange.
@Override
public void onChange(Registry.Changes<BackendService> changes) {
changes.removed().forEach(backendService -> routes.remove(backendService.path()).close());
concatenatedForEach(changes.added(), changes.updated(), backendService -> {
ProxyToClientPipeline pipeline = routes.get(backendService.path());
if (pipeline != null) {
pipeline.close();
}
boolean requestLoggingEnabled = environment.styxConfig().get("request-logging.outbound.enabled", Boolean.class).orElse(false);
boolean longFormat = environment.styxConfig().get("request-logging.outbound.longFormat", Boolean.class).orElse(false);
OriginStatsFactory originStatsFactory = new CachingOriginStatsFactory(environment.centralisedMetrics());
ConnectionPoolSettings poolSettings = backendService.connectionPoolConfig();
Connection.Factory connectionFactory = connectionFactory(backendService, requestLoggingEnabled, longFormat, originStatsFactory, poolSettings.connectionExpirationSeconds());
ConnectionPool.Factory connectionPoolFactory = new SimpleConnectionPoolFactory.Builder().connectionFactory(connectionFactory).connectionPoolSettings(backendService.connectionPoolConfig()).metrics(environment.centralisedMetrics()).build();
OriginHealthStatusMonitor healthStatusMonitor = healthStatusMonitor(backendService);
OriginsInventory inventory = new OriginsInventory.Builder(backendService.id()).eventBus(environment.eventBus()).metrics(environment.centralisedMetrics()).connectionPoolFactory(connectionPoolFactory).originHealthMonitor(healthStatusMonitor).initialOrigins(backendService.origins()).hostClientFactory(StyxHostHttpClient::create).build();
pipeline = new ProxyToClientPipeline(newClientHandler(backendService, inventory, originStatsFactory), () -> {
inventory.close();
healthStatusMonitor.stop();
});
routes.put(backendService.path(), pipeline);
LOG.info("added path={} current routes={}", backendService.path(), routes.keySet());
});
}
Aggregations