View Source Electric.Postgres.LockConnection (electric v0.9.5)
A Postgres connection that ensures an advisory lock is held for its entire duration, useful for ensuring only a single sync service instance can be using a single replication slot at any given time.
The connection attempts to grab the lock and waits on it until it acquires it.
When it does, it fires off an :exclusive_connection_lock_acquired message to the specified
Electric.Connection.Manager
such that the required setup can acquired now that
the service is sure to be the only one operating on this replication stream.
Summary
Types
@type option() :: {:connection_opts, Keyword.t()} | {:connection_manager, GenServer.server()} | {:lock_name, String.t()}
@type options() :: [option()]
Functions
@spec start_link(options()) :: {:ok, pid()} | {:error, Postgrex.Error.t() | term()}