Malachi. Cluster. RetentionCoordinator
(malachi v0.8.13)
View Source
Periodically expires sealed segments that exceed the retention policy, using the pure
Malachi.Cluster.Retention decision and executing it through injected seams, so it is testable
in-process and wired to the real broker/replication later without change:
:metadata_source-(-> Malachi.Metadata.t()), the current control-plane metadata;:expire_segment-(Malachi.Metadata.segment_meta() -> any), removes one expired segment from the control plane and deletes its stored data on the replicas;:policy- aMalachi.Cluster.Retention.policy()(:max_age_ms/:max_bytes;nil= off);:clock-(-> non_neg_integer())epoch ms (defaultSystem.system_time/1);:interval- the sweep period in ms (default 60_000);:leader?-(-> boolean()), whether this node should sweep (default always). Only the cluster's membership leader sweeps, so N nodes do not redo the same work (1C); a non-leader still ticks but skips the sweep.
Each sweep asks Retention.expired/3 which sealed segments to drop, resolves each to its metadata
(for its replica set), and calls expire_segment on it. run_now/1 runs one sweep synchronously,
ignoring :leader? (it is a manual trigger).
Summary
Functions
Returns a specification to start this module under a supervisor.
Runs one retention sweep synchronously; returns the list of expired segment ids.
Starts the coordinator. See the module doc for required options.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec run_now(GenServer.server()) :: [Malachi.Metadata.segment_id()]
Runs one retention sweep synchronously; returns the list of expired segment ids.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the coordinator. See the module doc for required options.