Lifecycle

Interface for components that have a lifecycle with start and stop operations.

Implementations of this interface can be started and stopped gracefully. The start method initializes the component, while stop methods handle shutdown.

This is useful for services, dispatchers, and other managed components.

Example usage:

class MyService : Lifecycle {
override fun start() {
// Initialize resources
println("Service started")
}

override fun stopGracefully(): Mono<Void> {
// Clean up
return Mono.empty()
}
}

val service = MyService()
service.start()
// ... use service ...
service.stop() // Graceful shutdown

See also

for stop operations

Inheritors

Functions

Link copied to clipboard
open override fun close()

Closes this resource by performing a graceful shutdown.

Link copied to clipboard
abstract fun start()

Starts this component, initializing resources and beginning operations.

Link copied to clipboard
open fun stop()

Synchronously closes this resource with graceful shutdown.

open fun stop(timeout: Duration)

Synchronously closes this resource with graceful shutdown within a specified timeout.

Link copied to clipboard
abstract fun stopGracefully(): Mono<Void>

Asynchronously closes this resource with graceful shutdown.