Owns every stats group's open Barograph database — a SQLite file plus a Graphite plaintext ingest listener bound to the group's configured port.
Supervised as a children/0 entry on PhoenixKitStats, so it starts
automatically inside the host app's PhoenixKit.Supervisor
(PhoenixKit.ModuleRegistry.static_children/0 collects it) — no
host-app supervision tree changes needed.
At boot, every status: "active" group is opened. A single group's
port-bind failure (e.g. the port is already taken by something else)
is logged as a warning and skipped — it must not crash the whole app.
Group create/update/pause/resume/delete call back into this GenServer
at runtime, so no app restart is ever required.
Summary
Functions
Returns a specification to start this module under a supervisor.
Closes a group's Barograph DB (if open) and frees its port. No-op if not open.
The directory Barograph .bg files are stored under. Requires
config :phoenix_kit_stats, data_dir: "..." — checked lazily, only
when a group actually needs opening, so a host that never enables any
group never needs to set it.
Returns the open Barograph db handle for a group, or {:error, :not_open}.
Opens (or re-opens) a group's Barograph DB + Graphite listener.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close_group(String.t(), GenServer.server()) :: :ok
Closes a group's Barograph DB (if open) and frees its port. No-op if not open.
@spec data_dir() :: {:ok, String.t()} | {:error, :not_configured}
The directory Barograph .bg files are stored under. Requires
config :phoenix_kit_stats, data_dir: "..." — checked lazily, only
when a group actually needs opening, so a host that never enables any
group never needs to set it.
@spec get_db(String.t(), GenServer.server()) :: {:ok, Barograph.db()} | {:error, :not_open}
Returns the open Barograph db handle for a group, or {:error, :not_open}.
@spec open_group(PhoenixKitStats.Schemas.Group.t(), GenServer.server()) :: :ok | {:error, term()}
Opens (or re-opens) a group's Barograph DB + Graphite listener.