GenericKtorService

Abstract base class for services that use an embedded Ktor CIO server for admin servlet hosting.

Hosts the admin endpoints (ping, version, health check, and thread dump servlets) via KtorServletService, delegating metrics, Zipkin tracing, health checks, and lifecycle coordination to AbstractGenericService.

Subclasses should call initKtorServletService during initialization to set up the service infrastructure.

The admin endpoints are served without authentication unless AdminConfig.filters add it, and the admin server binds only loopback unless AdminConfig.host names another interface. MetricsConfig.filters and MetricsConfig.host do the same for the metrics server.

The health check endpoint reports a check that fails with an exception as unhealthy with the message check failed and no error object: the exception's class, message and stack trace are logged instead of being sent to unauthenticated clients. A subclass that wants Dropwizard's full output registers HealthCheckServlet(healthCheckRegistry) at AdminConfig.healthCheckPath in the servletInit block.

Parameters

configVals

The application-specific configuration values.

adminConfig

Configuration for admin endpoints.

metricsConfig

Configuration for Prometheus metrics.

zipkinConfig

Configuration for Zipkin tracing.

versionBlock

A lambda returning the application version string for the version endpoint.

isTestMode

Whether the service is running in test mode.

Type Parameters

T

The type of the configuration values object.

See also

For a Jetty-based variant of this service.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Whether admin endpoints are enabled, based on AdminConfig.enabled.

Link copied to clipboard

Whether Prometheus metrics collection is enabled, based on MetricsConfig.enabled.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether Zipkin distributed tracing is enabled, based on ZipkinConfig.enabled.

Link copied to clipboard
lateinit var jmxReporter: JmxReporter

The JMX reporter for Dropwizard metrics. Initialized when metrics are enabled.

Link copied to clipboard

The Prometheus metrics service. Initialized when metrics are enabled.

Link copied to clipboard

The Ktor-based servlet service hosting admin endpoints. Initialized when admin is enabled.

Link copied to clipboard

The elapsed time since the service was created.

Link copied to clipboard

The Zipkin span reporter service. Initialized when Zipkin tracing is enabled.

Functions

Link copied to clipboard
fun addListener(listener: Service.Listener, executor: Executor)
Link copied to clipboard
fun awaitRunning(timeout: Duration)
fun awaitRunning(timeout: Long, unit: TimeUnit)
Link copied to clipboard
fun awaitTerminated(timeout: Long, unit: TimeUnit)
Link copied to clipboard
open override fun close()
Link copied to clipboard
Link copied to clipboard
fun initKtorServletService(initKtor: Application.() -> Unit = {}, servletInit: HttpServletGroup.() -> Unit = {})

Initializes the Ktor servlet service, metrics, Zipkin tracing, and health checks.

Link copied to clipboard
fun startAsync(): Service
Link copied to clipboard
fun startSync(timeout: Duration)
fun startSync(timeout: Duration)
Link copied to clipboard
fun state(): Service.State
Link copied to clipboard
fun stopAsync(): Service
Link copied to clipboard
fun stopSync(timeout: Duration)
fun stopSync(timeout: Duration)
Link copied to clipboard
open fun toString(): String