AuroraMeter.Exporter.Item (Aurora Meter v1.0.0)

View Source

One thing to deliver, and everything an adapter is allowed to know about it.

The caller builds it, usually from a durable row, and it is immutable from that moment: the same struct is handed to AuroraMeter.Exporter.deliver/2 on the first attempt and on the twentieth, with only attempts moving. Build one with AuroraMeter.Exporter.item!/1 so a half-built struct cannot reach an adapter.

FieldWhat it is
idthe caller's row id, opaque to the adapter, and the key of the tuple the adapter returns
subject_kind:usage_window, :event or :correction. The caller must not send a kind the adapter's supports list omits
subject_refthe caller's stable business reference: an event id, or "usage:<feature>:<period_start>:<from>:<to>"
tenant_keyfor logging, and for an adapter that must refuse an item belonging to another account
payloada map with string keys, already JSON safe. This is the financial intent, and Aurora Meter never looks inside it
attemptshow many previous attempts this item has had; 0 on the first
first_attempt_atwhen the first attempt was made, or nil before it. Stamped by the caller's database, not by a node clock

payload is where provider-specific fields live, and that is on purpose: an account id, a mode flag or a customer reference belongs there (or in the caller's own row), never in a field of this struct. Aurora Meter would then have to know what a provider is.

Summary

Types

t()

@type t() :: %AuroraMeter.Exporter.Item{
  attempts: non_neg_integer(),
  first_attempt_at: DateTime.t() | nil,
  id: String.t(),
  payload: %{optional(String.t()) => term()},
  subject_kind: AuroraMeter.Exporter.subject_kind(),
  subject_ref: String.t(),
  tenant_key: String.t()
}