Malachi.Storage.Layout (malachi v0.22.7)

View Source

Where a segment's files live on disk: the mapping from a control-plane segment_id to the directory holding that segment's log.

Kept apart from Malachi.Cluster.ReplicationServer because more than one component needs the same answer without going through the server's loop: the server itself opens and deletes segments, while Malachi.Cluster.Scrubber reads them to verify their checksums. One shared mapping means the scrub can never look in a different place than the writer.

Summary

Functions

The directory holding segment_id under base.

Functions

segment_directory(base, segment_id)

@spec segment_directory(Path.t(), term()) :: Path.t()

The directory holding segment_id under base.

Broker ids ({{topic, range_seq}, seg_seq}) get a readable name, topic-r<range>-s<segment>. Any other term (or a topic that is not path-safe) falls back to a collision-free Base64 encoding of the id, which keeps the directory inside base: segment ids arrive over inter-node replication, so the topic is not trusted here even though Malachi.Metadata screens the names of locally created topics.