View Source ProcessHub.Service.Storage.Dets (ProcessHub v0.7.0)
DETS-backed registry storage. Selected via
registry_backend: {:dets, opts} on ProcessHub.t().
Durability
Every successful mutation (insert/3, insert/4, remove/2,
clear_all/1) calls :dets.sync/1 before returning, so any operation
observed as :ok by the caller is durable on disk.
File location
By default the file is stored at
priv/process_hub/<hub_id>/registry.dets resolved against the
application's priv directory. Override with the :path option:
registry_backend: {:dets, path: "/var/lib/myapp/hub.dets"}The parent directory is created if it does not exist.
Recovery on corruption
On open the file is passed repair: true. If :dets.open_file/2
still returns {:error, _}, the corrupt file is rotated to
<path>.corrupt-<system_monotonic>, an error is logged, and a fresh
empty file is opened at the original path.
TTL
DETS has no native TTL. Entries inserted with :ttl are stored as
{key, value, expire_ms} (matching the ETS layout). Reads filter
expired entries on the way out. Expired rows are swept by
ProcessHub.Worker.Janitor.
Non-replaying open
The DETS file is both the durable medium and the live view for this
backend, so recovery_replay: false cannot be implemented by dropping
rows — that would destroy the very state a returning node needs. Instead
the keys present at open are recorded in a small in-memory shadow set
and filtered out of every read; they stay on disk and remain readable
through read_durable/1. Writing or removing a key un-shadows it, so a
row restored by the orphan reconcile becomes visible again.
Summary
Types
DETS table name paired with the shadow set of keys hidden from reads.