ServiceRegistry

interface ServiceRegistry

Minimal service registry ("DI-light").

Design note

A runtime registry keeps KTale adaptable to unknown host/container lifecycles. This avoids forcing a DI framework choice on Day 1.

Functions

Link copied to clipboard
abstract fun <T : Any> get(type: Class<T>): T?

Returns a service instance if registered, otherwise null.

Link copied to clipboard
inline fun <T : Any> ServiceRegistry.get(): T?
Link copied to clipboard
open fun <T : Any> register(type: Class<T>, instance: T)

Java-friendly overload (does not replace).

abstract fun <T : Any> register(type: Class<T>, instance: T, replace: Boolean)

Registers a service instance.

Link copied to clipboard
inline fun <T : Any> ServiceRegistry.register(instance: T, replace: Boolean = false)
Link copied to clipboard
abstract fun <T : Any> require(type: Class<T>): T

Returns a service instance or throws if missing.

Link copied to clipboard
inline fun <T : Any> ServiceRegistry.require(): T
Link copied to clipboard
abstract fun <T : Any> unregister(type: Class<T>)

Unregisters a service by type.

Link copied to clipboard
inline fun <T : Any> ServiceRegistry.unregister()