Bedrock.DataPlane.Log.Shale.Segment (bedrock v0.6.0)
View SourceRepresents a segment of the Shale transaction log.
Summary
Functions
Create a new segment from the given file path.
Types
@type t() :: %Bedrock.DataPlane.Log.Shale.Segment{ min_version: Bedrock.version(), path: String.t(), previous_version: Bedrock.version(), transactions: nil | [Bedrock.DataPlane.Transaction.encoded()] }
Functions
@spec allocate_from_recycler( Bedrock.DataPlane.Log.Shale.SegmentRecycler.server(), String.t(), Bedrock.version(), Bedrock.version() ) :: {:ok, t()} | {:error, :allocation_failed}
@spec allocate_from_recycler!( Bedrock.DataPlane.Log.Shale.SegmentRecycler.server(), String.t(), Bedrock.version(), Bedrock.version() ) :: t()
@spec decode_file_name(String.t()) :: pos_integer()
@spec encode_file_name(pos_integer()) :: String.t()
@spec file_prefix() :: String.t()
@spec from_path(path_to_file :: String.t()) :: {:ok, t()} | {:error, {:wal_format, String.t(), :unsupported_wal_format | :invalid_wal_format}} | {:error, {:wal_io, String.t(), File.posix()}}
Create a new segment from the given file path.
The header read itself is the existence check — no File.exists?/1
precheck, no check-then-open race. Failures keep their nature: bad bytes
are {:wal_format, path, reason} and never retried as resource trouble;
open/read failures are {:wal_io, path, posix} with their real POSIX
cause, never mislabeled as corruption.
@spec last_version(t()) :: Bedrock.version() | nil
@spec oldest_version(t()) :: Bedrock.version()
@spec return_to_recycler(t(), Bedrock.DataPlane.Log.Shale.SegmentRecycler.server()) :: :ok
@spec transactions(t()) :: [Bedrock.DataPlane.Transaction.encoded()]