LemonCore. ConfigReloader. Digest
(lemon_core v0.1.0)
View Source
Change detection via source fingerprinting for the config reloader.
Computes and compares digests for config sources (files, env, secrets) to determine whether a reload is necessary.
File fingerprints combine mtime + size + content hash for reliable detection. Secret digests use metadata only (owner, name, updated_at, version) — never values.
Summary
Functions
Compare two digest sets and return the list of sources that changed.
Compute a digest for the :env source.
Compute a fingerprint for a single file path.
Compute fingerprints for a list of file paths.
Compute a full digest for the :files source.
Compute a digest for the :secrets source.
Check whether a single source digest changed.
Types
@type digest_set() :: %{optional(source()) => source_digest()}
@type file_fingerprint() :: %{ path: String.t(), mtime: tuple() | nil, size: non_neg_integer() | nil, hash: binary() | nil, status: :ok | :missing | :error }
@type source() :: :files | :env | :secrets
@type source_digest() :: %{ source: source(), fingerprints: [file_fingerprint()] | [map()], computed_at_ms: non_neg_integer() }
Functions
@spec compare(digest_set(), digest_set()) :: {[source()], digest_set()}
Compare two digest sets and return the list of sources that changed.
Returns {changed_sources, new_digest_set}.
@spec env_digest(String.t() | nil) :: source_digest()
Compute a digest for the :env source.
Tracks the .env file fingerprint as the change signal.
@spec file_fingerprint(String.t()) :: file_fingerprint()
Compute a fingerprint for a single file path.
Returns mtime, size, and a SHA-256 content hash.
Missing or unreadable files are represented with status :missing or :error.
@spec file_fingerprints([String.t()]) :: [file_fingerprint()]
Compute fingerprints for a list of file paths.
@spec files_digest([String.t()]) :: source_digest()
Compute a full digest for the :files source.
@spec secrets_digest([map()]) :: source_digest()
Compute a digest for the :secrets source.
Uses metadata only (owner, name, updated_at, version) — secret values are never included.
@spec source_changed?(source_digest() | nil, source_digest() | nil) :: boolean()
Check whether a single source digest changed.