tuweni / org.apache.tuweni.hobbits / Relayer

Relayer

class Relayer : CoroutineScope (source)

Relays messages between two endpoints, with an interceptor reading passed messages.

Parameters

vertx - a Vert.x instance

bind - the endpoint to bind to

to - the endpoint to send to

interceptor - the interceptor function consuming messages being relayed

coroutineContext - the coroutine context of the relayer

Constructors

<init>

Relayer(vertx: Vertx, bind: String, to: String, interceptor: (Message) -> Unit, coroutineContext: CoroutineContext = Dispatchers.Default)

Relays messages between two endpoints, with an interceptor reading passed messages.

Properties

coroutineContext

val coroutineContext: CoroutineContext

the coroutine context of the relayer

Functions

start

suspend fun start(): Unit

Starts the relayer.

stop

fun stop(): Unit

Stops the relayer.

Extension Functions

asyncCompletion

fun CoroutineScope.asyncCompletion(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): AsyncCompletion

Starts new co-routine and returns its result as an implementation of AsyncCompletion. The running co-routine is cancelled when the resulting future is cancelled or otherwise completed.

asyncResult

fun <T> CoroutineScope.asyncResult(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): AsyncResult<T>

Starts new co-routine and returns its result as an implementation of AsyncResult. The running co-outine is cancelled when the resulting future is cancelled or otherwise completed.

retry

suspend fun <R> CoroutineScope.retry(retryDelay: Long, block: suspend (Int) -> R?): R
suspend fun <R> CoroutineScope.retry(retryDelay: Long, maxRetries: Int, block: suspend (Int) -> R?): R?
suspend fun <R> CoroutineScope.retry(retryDelay: (Int) -> Long?, block: suspend (Int) -> R?): R?

Retry a suspending block until a non-null result is obtained.