H.StoreLock (H v0.3.0)

Copy Markdown View Source

OS-level single-daemon ownership lock for data_dir.

Uses a short-lived .claim spin directory to serialize lock acquisition, then binds a Unix domain socket under /tmp (kept within macOS sun_path limits) and writes <data_dir>/lock.json. Surviving a SIGKILL of a prior daemon triggers :econnrefused on the stale socket probe, allowing immediate takeover without manual cleanup.

Summary

Functions

Returns a specification to start this module under a supervisor.

Computes the deterministic Unix domain socket path (<= 100 bytes) for data_dir.

Starts the store lock process for :data_dir.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

socket_path(data_dir)

@spec socket_path(String.t()) :: String.t()

Computes the deterministic Unix domain socket path (<= 100 bytes) for data_dir.

start_link(opts)

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

Starts the store lock process for :data_dir.

Returns {:error, :store_locked} if another live OS process holds the lock. Accepts an optional :name to register the GenServer.