TaskExecutionContext
data class TaskExecutionContext(val taskId: String, val retryCount: Int = 0, val payload: String? = null, val tags: Set<String> = emptySet())
Context provided to a task handler at execution time.
Available as the receiver inside handlers registered with context support:
kmpWorker.register("upload") { ctx ->
val data = ctx.payload?.let { Json.decodeFromString<MyData>(it) }
println("Attempt ${ctx.retryCount + 1} for ${ctx.taskId}")
uploadService.upload(data)
}Content copied to clipboard
Parameters
taskId
The unique ID of the task currently executing.
retryCount
Zero-based number of times this task has been retried.
payload
Optional serialized data from TaskRequest.payload.
tags
Tags attached to the original TaskRequest, if any.
Constructors
Properties
Functions
Link copied to clipboard
Decodes the payload of this TaskExecutionContext into a strongly-typed object.
Link copied to clipboard
Reports progress from within a task handler.