Owns the single write connection to a Barograph database (spec §7).
All writes funnel through this one process. Incoming samples are
buffered and committed in a single transaction when either
:batch_size samples are buffered or :batch_timeout milliseconds
have elapsed — whichever comes first (spec §7.2). If the buffer grows
beyond :max_buffer, writes are rejected with {:error, :overloaded}
rather than growing without bound.
Summary
Functions
All registered aggregate definitions.
Returns a specification to start this module under a supervisor.
Creates a continuous aggregate. See Barograph.Aggregate.create/4.
Synchronously commits any buffered samples.
Refreshes every registered aggregate up to now - lag.
Returns the database's time unit (:second, :millisecond, :microsecond).
Buffers a single sample for the next batch commit.
Buffers a list of {metric, labels, value, ts} samples.
Functions
@spec aggregate_definitions(GenServer.name()) :: [Barograph.Aggregate.definition()]
All registered aggregate definitions.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create_aggregate(GenServer.name(), String.t(), keyword()) :: :ok | {:error, term()}
Creates a continuous aggregate. See Barograph.Aggregate.create/4.
@spec flush(GenServer.name()) :: :ok
Synchronously commits any buffered samples.
@spec refresh_aggregates(GenServer.name()) :: :ok
Refreshes every registered aggregate up to now - lag.
@spec start_link(keyword()) :: GenServer.on_start()
@spec time_unit(GenServer.name()) :: atom()
Returns the database's time unit (:second, :millisecond, :microsecond).
Read from the Registry, not from the writer process — the unit is immutable per file, and the read path must not couple to writer liveness (e.g. during a long aggregate refresh).
@spec write(GenServer.name(), String.t(), map(), number(), integer() | nil) :: :ok | {:error, :overloaded}
Buffers a single sample for the next batch commit.
@spec write_many(GenServer.name(), [{String.t(), map(), number(), integer() | nil}]) :: :ok | {:error, :overloaded}
Buffers a list of {metric, labels, value, ts} samples.