API Reference Aurora Meter v#0.1.0
View SourceModules
Aurora Meter — real-time usage metering, plan entitlements, and Stripe-ready billing primitives for Phoenix.
Facade over the configured AuroraMeter.Billing.Provider
(AuroraMeter.Config.provider/0, default AuroraMeter.Billing.Noop).
Default billing provider: every operation returns {:error, :not_configured}.
Behaviour for a billing provider. The core ships AuroraMeter.Billing.Noop;
the Pro package provides a Stripe implementation. Only ever call a provider
through the AuroraMeter.Billing facade.
Fans live counter values out over Phoenix.PubSub on an interval, decoupled
from the (slower) database flush.
Drop-in HEEx components for showing live usage. Compiled only when
Phoenix.Component is available (the LiveView deps are optional).
Reads and validates Aurora Meter configuration from the :aurora_meter
application environment.
The hot path: atomic ETS counter operations.
Plan resolution and the entitlement gate.
Periodically persists dirty ETS counters to the database.
Helper for consuming live usage updates in a LiveView (or any process).
Creates and drops the Aurora Meter core tables.
Resolves the billing period a usage counter belongs to.
Default period source: calendar month in UTC.
A billing plan: an id, a monthly price (minor units / cents), and a map of feature configurations.
Compile-time DSL for declaring billing plans, plus runtime lookups.
A flushed snapshot of a usage counter for one {tenant_key, feature, period_start}. The live value lives in ETS; this row is the durable copy the
flusher upserts on an interval.
A raw usage event. Written only for features configured as :durable (and for
audit), giving billing-grade exactness beyond the buffered ETS counters.
A tenant's plan assignment. Created locally by AuroraMeter.subscribe/2 (free)
or synced from the billing provider (Pro). One row per tenant.
Behaviour for persisting Aurora Meter state, plus dispatch helpers that route to
the configured adapter (AuroraMeter.Config.storage/0, default
AuroraMeter.Storage.Ecto).
Default AuroraMeter.Storage adapter, backed by the host's Ecto repo
(AuroraMeter.Config.repo/0). Counter and event writes use insert_all for
throughput; counter upserts replace absolute values so flushes are idempotent.
Owns the ETS tables that back real-time metering.
Resolves an opaque tenant term into a stable string key.
Default tenant resolver: passes binaries through and stringifies anything that
implements String.Chars (integers, atoms, …). A term without String.Chars
raises Protocol.UndefinedError — configure a custom AuroraMeter.Tenant
implementation for structs.
Mix Tasks
Measures Aurora Meter's hot-path throughput: concurrent AuroraMeter.Counter
increments against warm ETS counters (no database on the hot path). This is the
evidence behind the BEAM-metering moat claim.
Generates a migration that installs the Aurora Meter tables into the host app.
Generates the Aurora Meter migration and prints the configuration you still
need to add. Equivalent to running aurora_meter.gen.migration plus a reminder.