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

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

@type aggregate_id() :: String.t()
@type config() :: keyword()
Link to this type

lock_acquisition_response()

View Source
@type 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
@spec 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
@spec release_lock(aggregate_id(), pid()) :: :ok

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

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