Tracks the active log file for each shard.
Uses atomics generation counter + process dictionary cache — ~15ns reads on the hot path. On file rotation, only an ETS re-read (~100ns) happens per caller process. No global GC from persistent_term.put, which matters when the host app has 50K+ LiveView/Channel processes.
Usage
# In Shard init and rotation:
ActiveFile.publish(shard_index, file_id, file_path, shard_data_path)
# In Router's async write path (hot path):
{file_id, file_path, shard_data_path} = ActiveFile.get(shard_index)
Summary
Functions
Returns {file_id, file_path, shard_data_path} for the given shard.
Initializes the registry. Called once from Application.start.
Publishes the active file metadata for a shard.
Functions
@spec get(non_neg_integer()) :: {non_neg_integer(), binary(), binary()}
Returns {file_id, file_path, shard_data_path} for the given shard.
~15ns hot path (atomics check + process dictionary cache hit). ~100ns cold (ETS lookup on generation mismatch).
@spec init(non_neg_integer()) :: :ok
Initializes the registry. Called once from Application.start.
@spec publish(non_neg_integer(), non_neg_integer(), binary(), binary()) :: :ok
Publishes the active file metadata for a shard.
Called from Shard.init/1 and Shard.maybe_rotate_file/1.