Canaryd.Store (canaryd v0.2.0)

Copy Markdown View Source

DETS-backed persistent state.

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

  • state.dets - latest state machine or monitor snapshot per target key: target name, 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.

Get a stored value, or return the given default.

All events, newest first, optionally filtered by target.

Append an event such as :hang_detected, :probe_fail, :restarted, or :blocked.

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.

get_value(table, key, default)

Get a stored value, or return the given 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 such as :hang_detected, :probe_fail, :restarted, or :blocked.

put_state(state_table, target, value)

with_tables(fun)

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