AuroraMeter.Store (Aurora Meter v0.4.0)

View Source

Owns the ETS tables that back real-time metering.

This process does nothing on the hot path — it merely creates and owns public, named ETS tables so that writers (AuroraMeter.Counter) and readers hit ETS directly without a GenServer bottleneck:

  • :aurora_meter_counters{tenant_key, feature, bucket} => value, where bucket is a period start (DateTime) or {:day, Date} for history
  • :aurora_meter_dirty — counter keys changed since the last database flush
  • :aurora_meter_touched — counter keys changed since the last PubSub broadcast
  • :aurora_meter_subscription_cachetenant_key => {subscription, expires_at}

It also listens on the subscription-invalidation PubSub topic so that a plan change applied on any node evicts the cached subscription on every node.

If this process crashes the tables are lost; its supervisor restarts it and the tables are recreated (counter state rehydrates lazily from the database).

Summary

Functions

Returns a specification to start this module under a supervisor.

The ETS table holding counter values.

The ETS table holding the dirty-key set (pending database flush).

The PubSub topic on which subscription changes are announced.

The ETS table caching subscription lookups.

The ETS table holding the touched-key set (pending PubSub broadcast).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

counters_table()

@spec counters_table() :: atom()

The ETS table holding counter values.

dirty_table()

@spec dirty_table() :: atom()

The ETS table holding the dirty-key set (pending database flush).

invalidation_topic()

@spec invalidation_topic() :: String.t()

The PubSub topic on which subscription changes are announced.

subscription_cache_table()

@spec subscription_cache_table() :: atom()

The ETS table caching subscription lookups.

touched_table()

@spec touched_table() :: atom()

The ETS table holding the touched-key set (pending PubSub broadcast).