AgentWorkshop.Persistence (AgentWorkshop v0.3.0)

Copy Markdown View Source

Persist work board, store, and events to disk.

Subscribes to PubSub and writes state to JSON files on change. On startup, loads saved state back into ETS tables so work survives IEx restarts.

Files

  • work.json -- full work board snapshot
  • store.json -- full store snapshot
  • events.jsonl -- append-only event log (one JSON object per line)

Configuration

configure(persistence: true)              # use .agent_workshop/ in cwd
configure(persistence: "/path/to/dir")    # custom directory

Persistence is disabled by default. When disabled, this GenServer is idle.

Summary

Functions

Returns a specification to start this module under a supervisor.

Disable persistence. Closes open file handles.

Enable persistence to the given directory.

Check if persistence is currently enabled.

Force an immediate flush of all pending writes.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

disable()

@spec disable() :: :ok

Disable persistence. Closes open file handles.

enable(dir)

@spec enable(boolean() | String.t()) :: :ok

Enable persistence to the given directory.

Pass true to use the default .agent_workshop/ in the current directory, or a path string for a custom location.

enabled?()

@spec enabled?() :: boolean()

Check if persistence is currently enabled.

flush()

@spec flush() :: :ok

Force an immediate flush of all pending writes.