ConduitMcp.Tasks.EtsStore (ConduitMCP v0.9.5)

Copy Markdown View Source

ETS-backed task store. Default implementation of ConduitMcp.Tasks.Store.

All state lives in the named ETS table :conduit_mcp_tasks. The table is owned by a long-lived Agent (ConduitMcp.Tasks.EtsStore.Owner) started from ConduitMcp.Application so the table outlives short-lived request processes — without this, a Bandit request handler that creates the table dies with it, and the next request sees an empty table. The table is :public so any process can read and write; concurrency is safe because each task id is the row key and rows are written atomically.

This store is in-memory only. Terminal-state rows accumulate until the BEAM restarts; pair it with ConduitMcp.Tasks.Janitor to evict them on an interval.

Summary

Functions

Cancels a task by setting status to "cancelled".

Removes terminal-state tasks (completed, failed, cancelled) older than ttl_ms. Tasks in working or input_required are never evicted. Returns the number of rows removed.

Creates a new task with the given id and metadata. Returns the stored task.

Deletes a task. Returns :ok whether or not it existed.

Fetches a task by id.

Lists all tasks, optionally filtered by :status.

Merges updates into the existing task. Returns the new task or {:error, :not_found}.

Functions

cancel(task_id)

Cancels a task by setting status to "cancelled".

cleanup(ttl_ms)

Removes terminal-state tasks (completed, failed, cancelled) older than ttl_ms. Tasks in working or input_required are never evicted. Returns the number of rows removed.

create(task_id, metadata \\ %{})

Creates a new task with the given id and metadata. Returns the stored task.

delete(task_id)

Deletes a task. Returns :ok whether or not it existed.

get(task_id)

Fetches a task by id.

list(opts \\ [])

Lists all tasks, optionally filtered by :status.

update(task_id, updates)

Merges updates into the existing task. Returns the new task or {:error, :not_found}.