Search in sources :

Example 1 with ServerConnector

use of com.hotels.styx.server.netty.ServerConnector in project styx by ExpediaGroup.

the class StyxServer method httpServer.

private InetServer httpServer(StyxServerComponents components, ConnectorConfig connectorConfig, HttpHandler styxDataPlane) {
    Environment environment = components.environment();
    CharSequence styxInfoHeaderName = environment.configuration().styxHeaderConfig().styxInfoHeaderName();
    ResponseInfoFormat responseInfoFormat = new ResponseInfoFormat(environment);
    ServerConnector proxyConnector = new ProxyConnectorFactory(environment.configuration().proxyServerConfig(), environment.centralisedMetrics(), environment.errorListener(), environment.configuration().get(ENCODE_UNWISECHARS).orElse(""), (builder, request) -> builder.header(styxInfoHeaderName, responseInfoFormat.format(request)), environment.configuration().get("requestTracking", Boolean.class).orElse(false), environment.httpMessageFormatter(), environment.configuration().styxHeaderConfig().originIdHeaderName()).create(connectorConfig);
    return NettyServerBuilder.newBuilder().setMetricsRegistry(environment.metricRegistry()).bossExecutor(proxyBossExecutor).workerExecutor(proxyWorkerExecutor).setProtocolConnector(proxyConnector).handler(styxDataPlane).build();
}
Also used : ServerConnector(com.hotels.styx.server.netty.ServerConnector) DISABLED(io.netty.util.ResourceLeakDetector.Level.DISABLED) LOGBackConfigurer.shutdownLogging(com.hotels.styx.infrastructure.logging.LOGBackConfigurer.shutdownLogging) Registry(com.hotels.styx.api.extension.service.spi.Registry) ServiceManager(com.google.common.util.concurrent.ServiceManager) Stopwatch(com.hotels.styx.javaconvenience.Stopwatch) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) CompletableFuture(java.util.concurrent.CompletableFuture) ENCODE_UNWISECHARS(com.hotels.styx.proxy.encoders.ConfigurableUnwiseCharsEncoder.ENCODE_UNWISECHARS) ConnectorConfig(com.hotels.styx.server.ConnectorConfig) NamedPlugin(com.hotels.styx.proxy.plugin.NamedPlugin) ArrayList(java.util.ArrayList) StyxServers.toGuavaService(com.hotels.styx.StyxServers.toGuavaService) CharStreams(com.google.common.io.CharStreams) SchemaValidationException(com.hotels.styx.config.schema.SchemaValidationException) AbstractService(com.google.common.util.concurrent.AbstractService) BackendService(com.hotels.styx.api.extension.service.BackendService) System.getProperty(java.lang.System.getProperty) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) NettyServerBuilder(com.hotels.styx.server.netty.NettyServerBuilder) AbstractStyxService(com.hotels.styx.api.extension.service.spi.AbstractStyxService) Logger(org.slf4j.Logger) HttpHandler(com.hotels.styx.api.HttpHandler) StyxServerComponents(com.hotels.styx.startup.StyxServerComponents) IOException(java.io.IOException) Reader(java.io.Reader) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) ResourceLeakDetector(io.netty.util.ResourceLeakDetector) CoreMetricsKt.registerCoreMetrics(com.hotels.styx.startup.CoreMetricsKt.registerCoreMetrics) MemoryBackedRegistry(com.hotels.styx.infrastructure.MemoryBackedRegistry) InputStreamReader(java.io.InputStreamReader) InetSocketAddress(java.net.InetSocketAddress) String.format(java.lang.String.format) Service(com.google.common.util.concurrent.Service) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) Resource(com.hotels.styx.api.Resource) Paths(java.nio.file.Paths) MeterRegistry(com.hotels.styx.api.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) LOGBackConfigurer.initLogging(com.hotels.styx.infrastructure.logging.LOGBackConfigurer.initLogging) BufferedReader(java.io.BufferedReader) Runtime.getRuntime(java.lang.Runtime.getRuntime) NotNull(org.jetbrains.annotations.NotNull) AdminServerBuilder(com.hotels.styx.admin.AdminServerBuilder) ServerConnector(com.hotels.styx.server.netty.ServerConnector) PrometheusConfig(io.micrometer.prometheus.PrometheusConfig)

Aggregations

CharStreams (com.google.common.io.CharStreams)1 AbstractService (com.google.common.util.concurrent.AbstractService)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 Service (com.google.common.util.concurrent.Service)1 ServiceManager (com.google.common.util.concurrent.ServiceManager)1 StyxServers.toGuavaService (com.hotels.styx.StyxServers.toGuavaService)1 AdminServerBuilder (com.hotels.styx.admin.AdminServerBuilder)1 HttpHandler (com.hotels.styx.api.HttpHandler)1 MeterRegistry (com.hotels.styx.api.MeterRegistry)1 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)1 Resource (com.hotels.styx.api.Resource)1 BackendService (com.hotels.styx.api.extension.service.BackendService)1 AbstractStyxService (com.hotels.styx.api.extension.service.spi.AbstractStyxService)1 Registry (com.hotels.styx.api.extension.service.spi.Registry)1 SchemaValidationException (com.hotels.styx.config.schema.SchemaValidationException)1 MemoryBackedRegistry (com.hotels.styx.infrastructure.MemoryBackedRegistry)1 LOGBackConfigurer.initLogging (com.hotels.styx.infrastructure.logging.LOGBackConfigurer.initLogging)1 LOGBackConfigurer.shutdownLogging (com.hotels.styx.infrastructure.logging.LOGBackConfigurer.shutdownLogging)1 Stopwatch (com.hotels.styx.javaconvenience.Stopwatch)1 ENCODE_UNWISECHARS (com.hotels.styx.proxy.encoders.ConfigurableUnwiseCharsEncoder.ENCODE_UNWISECHARS)1