Skip to main content

//clika-runtime/io.clika.runtime/Executor

Executor

[common]
class Executor

Drives one model: admits requests, runs its phases and delivers results. enqueue validates the request against the model's schema and answers at once; await blocks for the session's response; shutdown drains; a later enqueue fails with FAILED_PRECONDITION. AutoCloseable: close shuts down and releases the executor, and the model stays the caller's.

Executor.create(model).use { executor ->
val session = executor.enqueue(Request(mapOf("x" to x)))
executor.await(session).use { response -> println(response.output("y").toFloatArray().toList()) }
}

Types​

NameSummary
Companion[common]
object Companion

Functions​

NameSummary
await[common]
fun await(session: SessionId): Response
Block until session completes; its response, or the failure its phase body raised.
cancel[common]
fun cancel(session: SessionId)
Cooperatively cancel an in-flight session; a completed one is a no-op, an unknown one fails with NOT_FOUND.
close[common]
open fun close()
enqueue[common]
fun enqueue(request: Request): SessionId
Submit a request; fails with INVALID_ARGUMENT naming the input a declared slot refuses.
shutdown[common]
fun shutdown()
Drain in-flight work and stop; every accepted session completes and await still answers it.