Canaryd.Store (canaryd v0.1.0)

Copy Markdown View Source

DETS-backed persistent state.

Two tables live under ~/Library/Application Support/canaryd/:

  • state.dets - latest state machine snapshot per target key: target name (atom), value: map
  • events.dets - append-only event log key: {unix_usec, unique_integer}, value: event map

Each CLI run opens the tables, does its work, syncs and closes.

Summary

Functions

Get latest state for a target, or a fresh default.

All events, newest first, optionally filtered by target.

Append an event. type e.g. :probe_fail, :restarted, :blocked, :recovered, :system_warn.

Run fun with both tables open, guarded by an exclusive lockfile.

Functions

default_state()

dir()

get_state(state_table, target)

Get latest state for a target, or a fresh default.

list_events(events_table, target \\ nil, limit \\ 100)

All events, newest first, optionally filtered by target.

log_event(events_table, target, type, details \\ %{})

Append an event. type e.g. :probe_fail, :restarted, :blocked, :recovered, :system_warn.

put_state(state_table, target, value)

with_tables(fun)

Run fun with both tables open, guarded by an exclusive lockfile.