JobRegistry

Maps a job's stored kind string back to its JobType and JobHandler. Registration happens once at startup; lookups happen on every execution.

kinds is what the runtime hands to com.eventslooped.klokka.spi.JobStore.claim, so a worker only ever claims jobs it can run. A kind bound nowhere waits in Enqueued until a worker that binds it appears (a newer version mid-rollout, for example) rather than being dead-lettered by a worker that cannot run it. A claimed job whose kind is nevertheless unbound here means the store broke that contract; the runtime dead-letters it rather than requeue it, which could loop forever.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun <T> handle(type: JobType<T>, handler: JobHandler<T>, retry: RetryPolicy? = null, timeout: Duration? = null)

Binds handler to type. retry overrides the runtime default for this kind; it lives here, per kind and code-defined, so every node resolves the same policy (retry policies are functions and cannot be persisted per enqueue). Binding the same kind twice is an error.

fun <T> handle(type: JobType<T>, retry: RetryPolicy? = null, timeout: Duration? = null, block: suspend JobContext.(T) -> Unit)

Binds a suspend lambda to type. The lambda is wrapped in a JobHandler, so it has the same semantics as the object form and can be swapped for a class later without touching any enqueue site. retry and timeout as in the object form.

Link copied to clipboard
fun kinds(): Set<String>

The bound kind strings.

Link copied to clipboard
fun types(): List<JobType<*>>

Every bound JobType, in binding order. For startup checks and tooling; kinds are unique.