Fly.Postgres.LSN.Tracker (Fly Postgres v0.1.5) View Source
Track the current PostgreSQL LSN or Log Sequence Number.
This is used to determine which portions of the database log have been replicated locally. This lets us determine if a specific transaction chunk has been replicated to know that some expected data is present.
The client process doesn't interact directly with the Tracker GenServer. The
client can request_notification
or request_and_await_notification
and the
Tracker will notify the process when the data replication has been seen.
Link to this section Summary
Functions
Blocking function that waits for a request_notification/2
response message
to be received. The timeout defaults to 3s after which time it stops waiting
and returns an {:error, :timeout}
response.
Returns a specification to start this module under a supervisor.
Get the latest cached LSN replay value.
Callback implementation for GenServer.init/1
.
Return if the LSN value was replicated.
Request to be notified when the desired level of data replication has completed and wait for it to complete. Optionally it may timeout if it takes too long.
Request notification for when the database replication includes the LSN the process cares about. This allows a process to block and await their data to be replicated and be notified as soon as it's detected.
Start the Tracker that receives work requests.
Link to this section Functions
Specs
await_notification(Fly.Postgres.LSN.t(), timeout :: integer()) :: :ready | {:error, :timeout}
Blocking function that waits for a request_notification/2
response message
to be received. The timeout defaults to 3s after which time it stops waiting
and returns an {:error, :timeout}
response.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
get_last_replay(tab :: atom()) :: nil | Fly.Postgres.LSN.t()
Get the latest cached LSN replay value.
Callback implementation for GenServer.init/1
.
Return if the LSN value was replicated.
Specs
request_and_await_notification(Fly.Postgres.LSN.t(), timeout :: integer()) :: :ready | {:error, :timeout}
Request to be notified when the desired level of data replication has completed and wait for it to complete. Optionally it may timeout if it takes too long.
Specs
request_notification(tab :: atom(), Fly.Postgres.LSN.t()) :: :ok
Request notification for when the database replication includes the LSN the process cares about. This allows a process to block and await their data to be replicated and be notified as soon as it's detected.
Start the Tracker that receives work requests.