---
title: "Executor"
sidebar_label: "Executor"
description: "Kotlin binding reference: Executor."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Executor](index.md)

# Executor

[common]\
class [Executor](index.md)

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

```kotlin
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

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Functions

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