View Source ProcessHub.Service.Storage.DetsFile (ProcessHub v0.7.0)
On-disk DETS file management shared by the DETS-file storage backends
(ProcessHub.Service.Storage.Dets and ProcessHub.Service.Storage.DurableEts).
Covers path resolution, corruption rotation, and the durable-medium read. It is specific to persisting through a DETS file; in-memory or remote backends do not use it.
Summary
Functions
Syncs table unless the write asked for sync: false (a group commit syncs later).
Folds table into its non-expired {key, value} rows.
Resolves the on-disk path for hub_id (:path option, else priv/process_hub/<hub_id>/registry.dets).
Rotates a corrupt DETS file aside, logs at ERROR, and reopens a fresh file.
Functions
Syncs table unless the write asked for sync: false (a group commit syncs later).
Folds table into its non-expired {key, value} rows.
This is the read_durable/1 implementation shared by both DETS-file backends:
it reads the file only, never the live in-memory view either backend keeps
beside it. An unreadable file returns {:error, reason} — never an empty set,
which callers would mistake for "everything was deliberately removed".
Resolves the on-disk path for hub_id (:path option, else priv/process_hub/<hub_id>/registry.dets).
@spec rotate_and_reopen(atom(), String.t(), term()) :: {{:ok, atom()} | {:error, term()}, boolean()}
Rotates a corrupt DETS file aside, logs at ERROR, and reopens a fresh file.