Bedrock.DataPlane.Log.Shale.Writer (bedrock v0.5.3)

View Source

A struct that represents a writer for a segment.

Summary

Types

t()

A Writer is a handle to a segment that can be used to write transcations to the segment. It is a stateful object that keeps track of the current write offset and the number of bytes remaining in the segment.

Types

t()

@type t() :: %Bedrock.DataPlane.Log.Shale.Writer{
  bytes_remaining: pos_integer(),
  fd: File.file_descriptor(),
  sync_fun: (File.file_descriptor() -> :ok | {:error, File.posix()}),
  write_offset: pos_integer()
}

A Writer is a handle to a segment that can be used to write transcations to the segment. It is a stateful object that keeps track of the current write offset and the number of bytes remaining in the segment.

Functions

append(writer, transaction, commit_version)

@spec append(t(), Bedrock.DataPlane.Transaction.encoded(), Bedrock.version()) ::
  {:ok, t()} | {:error, :segment_full} | {:error, File.posix()}

close(writer)

@spec close(writer :: t() | nil) :: :ok | {:error, File.posix()}

open(path_to_file, opts \\ [])

@spec open(path_to_file :: String.t(), opts :: keyword()) ::
  {:ok, t()} | {:error, File.posix()}