Documentation
¶
Overview ¶
Package swap manages atomic state-table version pointers for backfill cutover.
The lambda-replay backfill pattern:
- Live pipeline writes to "<alias>_v<N>" (e.g. "page_views_v3").
- Backfill replay job runs into a fresh "<alias>_v<N+1>" — independent of live.
- When replay completes, the operator (or automation) calls Manager.SetActive to atomically advance the alias pointer.
- Query layer rolls / refreshes; clients now see results from v<N+1>.
- Old v<N> is dropped after a grace period.
The control table is a single DDB table holding one row per alias:
pk: "<alias>" (S) ver: <version> (N) at: <unix-ms> (N) — last update timestamp
SetActive uses a conditional UpdateExpression so concurrent swap attempts can't regress (only ver > current-ver is accepted).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoActiveVersion = errors.New("swap: no active version for alias")
ErrNoActiveVersion is returned by GetActive when no pointer has been set yet for the alias.
var ErrVersionRegressed = errors.New("swap: cannot regress version")
ErrVersionRegressed is returned by SetActive when the requested version is not strictly greater than the current active version.
Functions ¶
func CreateControlTable ¶
CreateControlTable creates the control table with the schema expected by Manager. Production tables should be created via Terraform; this helper exists for tests and dev-loop convenience.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager reads and writes version pointers in the control table.
func New ¶
New constructs a Manager. The control table must already exist; CreateControlTable is the convenience helper.
func (*Manager) GetActive ¶
GetActive returns the current active version for alias. Returns ErrNoActiveVersion if none has been set.
func (*Manager) Resolve ¶
Resolve combines GetActive with TableName: returns "<alias>_v<active>" or, if no version has been set, "<alias>_v1" as the implicit-bootstrap convention.