BrokerCoroutines

Interface representing a coroutine-based message broker that supports sending, receiving, and responding to messages.

Functions

Link copied to clipboard
abstract override fun close()

Closes the message broker and releases any resources it holds.

Link copied to clipboard
abstract suspend fun initialize()

Initializes the message broker, performing any necessary setup or initialization tasks.

Link copied to clipboard
abstract suspend fun <T : Any> listen(handler: HandlerCoroutines<T>): AutoCloseable
abstract suspend fun <T : Any> listen(type: KClass<T>, handler: suspend (T) -> Unit): AutoCloseable

Registers a handler to listen for messages of a specific type.

Link copied to clipboard
inline suspend fun <T : Any> BrokerCoroutines.listen(noinline handler: suspend (T) -> Unit): AutoCloseable

Registers a handler to listen for messages of a specific type.

Link copied to clipboard
abstract suspend fun <R : Any> request(message: Any, responseType: KClass<R>, vararg targets: Target): R
abstract suspend fun <R : Any> request(message: Any, responseType: KClass<R>, targets: Collection<Target>): R

Sends a request and awaits a response using the default timeout.

abstract suspend fun <R : Any> request(message: Any, responseType: KClass<R>, timeout: Duration, vararg targets: Target): R
abstract suspend fun <R : Any> request(message: Any, responseType: KClass<R>, timeout: Duration, targets: Collection<Target>): R

Sends a request and awaits a response within a specified timeout.

Link copied to clipboard
inline suspend fun <R : Any> BrokerCoroutines.request(message: Any, vararg targets: Target): R

Sends a request and awaits a response using the default timeout.

inline suspend fun <R : Any> BrokerCoroutines.request(message: Any, timeout: Duration, vararg targets: Target): R

Sends a request and awaits a response within a specified timeout.

Link copied to clipboard
abstract suspend fun <T : Any, Y : Any> respond(responder: ResponderCoroutines<T, Y>): AutoCloseable

Registers a responder to handle incoming messages of a specific type and produce a response.

abstract suspend fun <T : Any, Y : Any> respond(type: KClass<T>, responder: suspend (T) -> Y?): AutoCloseable

Registers a function to respond to incoming messages of a specific type.

Link copied to clipboard
inline suspend fun <T : Any, R : Any> BrokerCoroutines.respond(noinline handler: suspend (T) -> R?): AutoCloseable

Registers a function to respond to incoming messages of a specific type.

Link copied to clipboard
abstract suspend fun send(message: Any, vararg targets: Target)

Sends a message to the specified targets.

abstract suspend fun send(message: Any, targets: Collection<Target>)

Sends a message to the specified collection of targets.