Incident.EventStore.Postgres.LockManager (incident v0.6.1) View Source

Manages aggregate locks for the Postgres adapter.

The Lock Manager can be configured during initialization for the retry logic and lock timeout.

Link to this section Summary

Functions

Attempts to acquire a lock for the aggregate id. It uses the lock manager configuration for retry logic. In case the lock can't be acquired after all retry attempts, it will return an error.

Returns a specification to start this module under a supervisor.

Removes the lock for the aggregate id that belongs to the caller.

Link to this section Types

Specs

aggregate_id() :: String.t()

Specs

config() :: keyword()
Link to this type

lock_acquisition_response()

View Source

Specs

lock_acquisition_response() :: :ok | {:error, :already_locked | :failed_to_lock}

Link to this section Functions

Link to this function

acquire_lock(aggregate_id, owner)

View Source

Specs

acquire_lock(aggregate_id(), pid()) :: lock_acquisition_response()

Attempts to acquire a lock for the aggregate id. It uses the lock manager configuration for retry logic. In case the lock can't be acquired after all retry attempts, it will return an error.

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

release_lock(aggregate_id, owner)

View Source

Specs

release_lock(aggregate_id(), pid()) :: :ok

Removes the lock for the aggregate id that belongs to the caller.

Specs

start_link(keyword()) :: GenServer.on_start()