Lockspire.Storage.ServerPolicyStore behaviour
(lockspire v1.0.0)
Copy Markdown
Domain-level persistence contract for Lockspire server policy.
Summary
Callbacks
Atomically read-merge-write the server-policy singleton row under FOR UPDATE lock.
Types
@type store_error() :: term()
Callbacks
@callback get_server_policy() :: {:ok, Lockspire.Domain.ServerPolicy.t()} | {:error, store_error()}
@callback put_server_policy(Lockspire.Domain.ServerPolicy.t()) :: {:ok, Lockspire.Domain.ServerPolicy.t()} | {:error, store_error()}
@callback update_server_policy((Lockspire.Domain.ServerPolicy.t() -> Lockspire.Domain.ServerPolicy.t())) :: {:ok, Lockspire.Domain.ServerPolicy.t()} | {:error, store_error()}
Atomically read-merge-write the server-policy singleton row under FOR UPDATE lock.
The mutator is invoked with the current %ServerPolicy{} (or a default struct when no
durable row exists) inside the same transaction that locks the row, so concurrent admin
writes serialise rather than racing across two Repository calls.
Required by Admin.ServerPolicy.put_server_policy/1 and
Admin.ServerPolicy.put_dcr_policy/1 to preserve unrelated fields on the singleton row
without lost-update races.