All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.assembly.RaptorKtorPlugin.kt Maven / Gradle / Ivy

There is a newer version: 0.26.0
Show newest version
package io.fluidsonic.raptor.ktor

import io.fluidsonic.raptor.*
import io.fluidsonic.raptor.lifecycle.*
import io.fluidsonic.raptor.transactions.*


public object RaptorKtorPlugin : RaptorPlugin {

	override fun RaptorPluginCompletionScope.complete() {
		completeComponents()

		propertyRegistry.register(Keys.ktorProperty, componentRegistry.one(Keys.ktorComponent).complete(context = lazyContext))
	}


	override fun RaptorPluginInstallationScope.install() {
		require(RaptorLifecyclePlugin)
		require(RaptorTransactionPlugin)

		componentRegistry.register(Keys.ktorComponent, RaptorKtorComponent())

		lifecycle {
			onStart("ktor server", priority = Int.MIN_VALUE) {
				checkNotNull(context.ktorInternal).start()
			}
			onStop("ktor server", priority = Int.MAX_VALUE) {
				checkNotNull(context.ktorInternal).stop()
			}
		}
	}


	override fun toString(): String = "ktor"
}


@RaptorDsl
public val RaptorAssemblyScope.ktor: RaptorKtorComponent
	get() = componentRegistry.oneOrNull(Keys.ktorComponent) ?: throw RaptorPluginNotInstalledException(RaptorKtorPlugin)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy