View Source Electric.Timeline (electric v0.9.5)

Module exporting functions for handling Postgres timelines. Verifies the Postgres ID and its timeline.

Summary

Functions

Checks that we're connected to the same Postgres DB as before and on the same timeline. TO this end, it checks the provided pg_id against the persisted PG ID. If the PG IDs match, it also checks the provided pg_timeline against the persisted timeline. Normally, Postgres and Electric are on the same timeline and nothing must be done. If the timelines differ, that indicates that a Point In Time Recovery (PITR) has occurred and all shapes must be cleaned. If we fail to fetch timeline information, we also clean all shapes for safety as we can't be sure that Postgres and Electric are on the same timeline.

Types

@type check_result() :: :ok | :timeline_changed
@type pg_id() :: non_neg_integer()
@type timeline() :: {pg_id(), timeline_id()} | nil
@type timeline_id() :: integer()

Functions

Link to this function

check(pg_timeline, opts)

View Source
@spec check(
  timeline(),
  keyword()
) :: check_result()

Checks that we're connected to the same Postgres DB as before and on the same timeline. TO this end, it checks the provided pg_id against the persisted PG ID. If the PG IDs match, it also checks the provided pg_timeline against the persisted timeline. Normally, Postgres and Electric are on the same timeline and nothing must be done. If the timelines differ, that indicates that a Point In Time Recovery (PITR) has occurred and all shapes must be cleaned. If we fail to fetch timeline information, we also clean all shapes for safety as we can't be sure that Postgres and Electric are on the same timeline.

@spec load_timeline(Keyword.t()) :: timeline()
Link to this function

store_timeline(arg, opts)

View Source
@spec store_timeline(timeline(), Keyword.t()) :: :ok