register

fun register(id: String, block: suspend TaskExecutionContext.() -> Unit)

Registers a suspend handler for the given task ID.

The handler receives a TaskExecutionContext with the task ID, retry count, and any payload attached to the TaskRequest. Unused if you don't need it:

// Simple — context available but ignored
register("sync") { repository.sync() }

// With context
register("sync") { ctx -> println("attempt ${ctx.retryCount}") }

Overwrites any existing handler for the same ID.