BaseApplicationEngine

abstract class BaseApplicationEngine(val environment: ApplicationEnvironment, monitor: Events, developmentMode: Boolean, val pipeline: EnginePipeline = defaultEnginePipeline(environment.config, developmentMode)) : ApplicationEngine

Base class for implementing ApplicationEngine

It creates default engine pipeline, provides application property and installs default transformations on respond and receive

Parameters

environment

instance of ApplicationEnvironment for this engine

pipeline

pipeline to use with this engine

Constructors

Link copied to clipboard
constructor(environment: ApplicationEnvironment, monitor: Events, developmentMode: Boolean, pipeline: EnginePipeline = defaultEnginePipeline(environment.config, developmentMode))

Types

Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
expect fun ApplicationEngine.addShutdownHook(monitor: Events, stop: () -> Unit)

Adds automatic application shutdown hooks management. Should be used before starting the engine. Once application termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

actual fun ApplicationEngine.addShutdownHook(monitor: Events, stop: () -> Unit)

Configures automatic management of JVM shutdown hooks for terminating an application. This function should be invoked before starting the application engine. Once the JVM termination is detected, the stop block will be executed. Please note that a shutdown hook is registered only while the application is running. If the application has already stopped, the hook won't be registered, and invoking stop will have no effect. Therefore, the stop block will be called either once or not at all.

actual fun ApplicationEngine.addShutdownHook(monitor: Events, stop: () -> Unit)

Adds automatic application shutdown hooks management. Should be used before starting the engine. Once application termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

Link copied to clipboard
open suspend override fun resolvedConnectors(): List<EngineConnectorConfig>

Local addresses for application connectors. If environment's connectors was configured to use port=0, you can use this function to get an actual port for these connectors. Available after a server is started.

Link copied to clipboard
abstract fun start(wait: Boolean = false): ApplicationEngine

Starts this ApplicationEngine.

Link copied to clipboard
abstract fun stop(gracePeriodMillis: Long = 500, timeoutMillis: Long = 500)

Stops this ApplicationEngine.

Link copied to clipboard
fun ApplicationEngine.stop(gracePeriod: Long, timeout: Long, timeUnit: TimeUnit)
Link copied to clipboard
fun ApplicationEngine.stopServerOnCancellation(application: Application, gracePeriodMillis: Long = 50, timeoutMillis: Long = 5000): CompletableJob

Stop server on job cancellation. The returned deferred need to be completed or cancelled.