ConduitMcp.Tasks.Janitor (ConduitMCP v0.9.5)

Copy Markdown View Source

Periodically prunes terminal-state tasks from ConduitMcp.Tasks.

ConduitMcp.Tasks stores task state in a named ETS table (:conduit_mcp_tasks) that has no eviction loop of its own — tasks that reach completed, failed, or cancelled linger in memory until the BEAM restarts. The janitor wakes on an interval and calls ConduitMcp.Tasks.cleanup/1 to drop terminal-state entries older than the configured TTL.

Tasks still in working or input_required are never evicted by the janitor regardless of age — long-running tasks remain available.

Usage

children = [
  {ConduitMcp.Tasks.Janitor,
   ttl: :timer.hours(1),
   interval: :timer.minutes(5)}
]

Options

  • :ttl — maximum age in milliseconds for terminal-state tasks (default: 1 hour).
  • :interval — interval between cleanup runs in milliseconds (default: 5 minutes).
  • :name — registered process name (default: module name).

Emits [:conduit_mcp, :tasks, :cleanup] telemetry on each run with measurements %{removed: count}.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])