Lucerna.Gates.Store (Lucerna v0.0.1-alpha.0)

The boring ETS owner. Holds the snapshot table and does exactly two things: apply snapshots and settle the ready gate. All crash-prone work (HTTP, decode, backoff) lives in Lucerna.Gates.Sync — the supervisor's one_for_one strategy exists precisely so a Sync crash cannot take this table down with it.

Table layout (:protected, :named_table, read_concurrency):

  • {{:kill, key}, boolean} / {{:flag, key}, map} / {{:experiment, key}, map} / {{:audience, id}, map} — one row per gate, so a read copies one gate's rules out of ETS, never the whole snapshot.
  • {:document, map} — the last wire document, for evaluate, inspect_gate and runtime (cold paths).
  • {:etag, binary | nil} — lives here, not in Sync, so a Store restart (fresh empty table) also resets the conditional-fetch state and the next poll refetches instead of trusting a 304.

  • {:meta, map} — environment / generatedAt; presence means loaded.

Summary

Functions

Applies a fetched snapshot. Called by Sync only.

Settles the ready gate as auth-failed. Called by Sync only.

Blocks until the first snapshot lands. Returns :ready or {:auth_failed, error}; callers translate. Timeouts are the caller's (GenServer.call timeout).

Returns a specification to start this module under a supervisor.

Functions

apply_snapshot(store, document, etag)

Applies a fetched snapshot. Called by Sync only.

auth_failed(store, error)

Settles the ready gate as auth-failed. Called by Sync only.

await_ready(store, timeout)

Blocks until the first snapshot lands. Returns :ready or {:auth_failed, error}; callers translate. Timeouts are the caller's (GenServer.call timeout).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.