AuroraMeter.Period behaviour (Aurora Meter v0.1.0)

View Source

Resolves the billing period a usage counter belongs to.

current/2 delegates to the configured :period_source (ADR 0003), which defaults to AuroraMeter.Period.Calendar (calendar month, UTC). Pro overrides it with subscription-aligned bounds — without any change to core call sites.

Summary

Types

t()

A resolved billing window.

Callbacks

Returns the active period for tenant at now.

Functions

Returns the active billing period for tenant.

Types

t()

@type t() :: %{start: DateTime.t(), end: DateTime.t(), source: atom()}

A resolved billing window.

Callbacks

current(tenant, now)

@callback current(tenant :: term(), now :: DateTime.t()) :: t()

Returns the active period for tenant at now.

Functions

current(tenant, now \\ DateTime.utc_now())

@spec current(term(), DateTime.t()) :: t()

Returns the active billing period for tenant.

Examples

iex> p = AuroraMeter.Period.current("org_1")
iex> match?(%{start: %DateTime{}, end: %DateTime{}, source: _}, p)
true