API Reference Aurora Meter v#0.3.1
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, and ships this node's deltas to the other
nodes.
Keeps every node's counters converging on the same totals.
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, and once more on shutdown so a deploy never drops the last interval of usage.
Helper for consuming live usage updates in a LiveView (or any process).
Creates and drops the Aurora Meter core tables, in versions.
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 flushed snapshot of a usage history bucket (bucket_kind "day", UTC) for
one {tenant_key, feature, bucket_start}. Maintained by the flusher alongside
the period counters when :history is enabled, and read by
AuroraMeter.history/3 for charts.
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.
Cached subscription lookups.
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.
Helpers for testing an application that uses Aurora Meter.
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.
Installs Aurora Meter into a Phoenix (or plain Ecto) application in one step, powered by Igniter