gbr/disk_log/core

gbr/disk_log/core: Core implementation for Erlang’s disk_log wrapper.

This module handles the FFI (Foreign Function Interface) calls to Erlang’s disk_log and provides the opaque types for logs and options.

It is not intended to be used directly by most applications. Use the gbr/disk_log facade instead for a more idiomatic experience and to enable pattern matching on public types.

Types

Data structure for reading chunks of terms from the log.

pub type ChunkData {
  Eof
  Chunk(continuation: Continuation, terms: List(BitArray))
}

Constructors

  • Eof

    End of log file reached.

  • Chunk(continuation: Continuation, terms: List(BitArray))

    A chunk of log terms and the next continuation.

Opaque continuation used for reading chunks from the log.

pub type Continuation {
  Continuation(dynamic.Dynamic)
}

Constructors

Error type for disk log operations.

pub type DiskLogError {
  DiskLogError(reason: String)
}

Constructors

  • DiskLogError(reason: String)

    A general error with a descriptive reason.

Opaque handle to a disk log process.

  • name: Atom disk log instance.

https://www.erlang.org/doc/apps/kernel/disk_log.html

pub opaque type LogDisk

Possible formats for the log file data.

pub type LogFormat {
  Internal
  External
}

Constructors

  • Internal

    Internal Erlang binary format.

  • External

    External raw binary format.

Current information about a log.

pub type LogInfo {
  LogInfo(
    name: String,
    file: String,
    type_: LogType,
    format: LogFormat,
    size: LogSize,
    mode: LogMode,
  )
}

Constructors

The access mode for the log file.

pub type LogMode {
  ReadOnly
  ReadWrite
}

Constructors

  • ReadOnly

    Open the log in read-only mode.

  • ReadWrite

    Open the log in read-write mode.

Opaque configuration options for a disk log.

https://www.erlang.org/doc/apps/kernel/disk_log.html#open/1

pub opaque type LogOpts

Strategies for repairing a disk log.

pub type LogRepair {
  Enable
  Truncate
  Disabled
}

Constructors

  • Enable

    Attempt to repair the log if corrupted.

  • Truncate

    Truncate the log if corruption is found.

  • Disabled

    Do not attempt repair.

Maximum allowed size for a disk log.

pub type LogSize {
  Infinity
  MaxBytes(Int)
  WrapSize(max_bytes: Int, max_files: Int)
}

Constructors

  • Infinity

    No size limit.

  • MaxBytes(Int)

    Limit by total bytes for a single file.

  • WrapSize(max_bytes: Int, max_files: Int)

    Limit by total bytes and total number of files for wrap logs.

Supported log types for the disk log module.

pub type LogType {
  Halt
  Wrap
  Rotate
}

Constructors

  • Halt

    Halt logs write items to a single file.

  • Wrap

    Wrap logs use a sequence of files of limited size.

  • Rotate

    Rotate logs rotate and compress files (external format only).

A module, function, and arguments tuple for callback functions.

pub type MFA =
  #(atom.Atom, atom.Atom, List(dynamic.Dynamic))

Values

pub fn alog(
  log: LogDisk,
  data: BitArray,
) -> Result(LogDisk, DiskLogError)

Log data asynchronously.

pub fn balog(
  log: LogDisk,
  data: BitArray,
) -> Result(LogDisk, DiskLogError)

Log binary data asynchronously.

pub fn block(
  log: LogDisk,
  queue: Bool,
) -> Result(LogDisk, DiskLogError)

Block a log process.

pub fn chunk(
  log: LogDisk,
  cont: Continuation,
) -> Result(ChunkData, DiskLogError)

Read a chunk of data from the log.

pub fn close(log: LogDisk) -> Result(LogDisk, DiskLogError)

Close a log.

pub fn file(opts: LogOpts, file: String) -> LogOpts

Set the file path in the options.

pub fn format(opts: LogOpts, format: LogFormat) -> LogOpts

Set the log format in the options.

pub fn inc_wrap_file(
  log: LogDisk,
) -> Result(LogDisk, DiskLogError)

Increment the wrap file counter.

pub fn info(log: LogDisk) -> Result(LogInfo, DiskLogError)

Get info about the log.

pub fn log(
  log: LogDisk,
  data: BitArray,
) -> Result(LogDisk, DiskLogError)

Log data synchronously.

pub fn new(name: String) -> LogDisk

Create a new LogDisk handle from a name.

pub fn open(log: LogDisk) -> Result(LogDisk, DiskLogError)

Open a log with default options.

pub fn open_opts(
  log: LogDisk,
  opts: LogOpts,
) -> Result(LogDisk, DiskLogError)

Open a log with specific options.

pub const opts_empty: LogOpts

Default empty options.

pub fn repair(opts: LogOpts, repair: LogRepair) -> LogOpts

Set the repair strategy in the options.

pub fn size(opts: LogOpts, size: LogSize) -> LogOpts

Set the log size in the options.

pub fn start_continuation() -> Continuation

Get the initial continuation.

pub fn sync(log: LogDisk) -> Result(LogDisk, DiskLogError)

Force sync log data to disk.

pub fn type_(opts: LogOpts, type_: LogType) -> LogOpts

Set the log type in the options.

pub fn unblock(log: LogDisk) -> Result(LogDisk, DiskLogError)

Unblock a log process.

Search Document