TaskStateManager

Manages task state and history for streaming and resubscription support. Tracks active tasks, completed tasks, and their event history.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class TaskInfo(val taskId: String, val contextId: String, val streamId: String, val events: MutableList<<Error class: unknown class>> = mutableListOf(), val createdAt: Instant = Instant.now(), var completedAt: Instant? = null, var currentState: <Error class: unknown class> = TaskState.WORKING)

Stores information about a task

Functions

Link copied to clipboard
fun cleanupOldTasks(olderThan: Instant)

Removes old completed tasks (basic cleanup)

Link copied to clipboard
fun getStreamId(taskId: String): String?

Gets the stream ID associated with a task

Link copied to clipboard
fun getTaskEvents(taskId: String): List<<Error class: unknown class>>

Gets all events for a task

Link copied to clipboard

Gets the task info for a given task ID

Link copied to clipboard

Checks if a task is active

Link copied to clipboard
fun recordEvent(taskId: String, event: <Error class: unknown class>)

Records an event for a task

Link copied to clipboard
fun registerTask(taskId: String, contextId: String, streamId: String)

Registers a new task with its stream ID

Link copied to clipboard
fun taskExists(taskId: String): Boolean

Checks if a task exists (active or completed)

Link copied to clipboard
fun updateStreamId(taskId: String, newStreamId: String)

Updates the stream ID for a task (used during resubscription)