RaftedValue.Snapshot (rafted_value v0.12.0)

Copy Markdown View Source

Summary

Functions

Type-aware getter for command_results.

Type-aware setter for command_results.

Type-aware getter for config.

Type-aware setter for config.

Type-aware getter for data.

Type-aware setter for data.

Type-aware getter for last_committed_entry.

Type-aware setter for last_committed_entry.

Type-aware getter for members.

Type-aware setter for members.

Creates a new instance of RaftedValue.Snapshot by using the given dict.

A variant of new/1 which returns t or raise if validation fails.

Type-aware getter for term.

Type-aware setter for term.

Updates an existing instance of RaftedValue.Snapshot with the given dict. The values in the dict are validated by each field's valid?/1 function. Returns {:ok, valid_struct} or {:error, reason}.

A variant of update/2 which returns t or raise if validation fails. In other words, update/2 followed by Croma.Result.get!/1.

Checks if the given value belongs to t/0 or not.

Types

t()

@type t() :: %RaftedValue.Snapshot{
  command_results: RaftedValue.CommandResults.t(),
  config: RaftedValue.Config.t(),
  data: Croma.Any.t(),
  last_committed_entry: RaftedValue.LogEntry.t(),
  members: RaftedValue.Members.t(),
  term: RaftedValue.TermNumber.t()
}

Functions

command_results(snapshot)

@spec command_results(t()) :: RaftedValue.CommandResults.t()

Type-aware getter for command_results.

command_results(s, field)

@spec command_results(t(), RaftedValue.CommandResults.t()) :: t()

Type-aware setter for command_results.

config(snapshot)

@spec config(t()) :: RaftedValue.Config.t()

Type-aware getter for config.

config(s, field)

@spec config(t(), RaftedValue.Config.t()) :: t()

Type-aware setter for config.

data(snapshot)

@spec data(t()) :: Croma.Any.t()

Type-aware getter for data.

data(s, field)

@spec data(t(), Croma.Any.t()) :: t()

Type-aware setter for data.

decode(bin)

@spec decode(binary()) :: t()

encode(snapshot)

@spec encode(t()) :: binary()

from_install_snapshot(is)

@spec from_install_snapshot(RaftedValue.RPC.InstallSnapshot.t()) :: t()

last_committed_entry(snapshot)

@spec last_committed_entry(t()) :: RaftedValue.LogEntry.t()

Type-aware getter for last_committed_entry.

last_committed_entry(s, field)

@spec last_committed_entry(t(), RaftedValue.LogEntry.t()) :: t()

Type-aware setter for last_committed_entry.

members(snapshot)

@spec members(t()) :: RaftedValue.Members.t()

Type-aware getter for members.

members(s, field)

@spec members(t(), RaftedValue.Members.t()) :: t()

Type-aware setter for members.

new(dict)

@spec new(term()) :: Croma.Result.t(t())

Creates a new instance of RaftedValue.Snapshot by using the given dict.

Values associated with the struct field names are fetched from the given dict and then validated/converted with valid?/1/new/1. For missing fields default values (if any) are used.

Returns {:ok, valid_struct} when all fields are filled with valid values. Returns {:error, reason} if any error occurs (invalid value or no value is available).

See also moduledoc of Croma.Struct.

new!(dict)

@spec new!(term()) :: t()

A variant of new/1 which returns t or raise if validation fails.

In other words, new/1 followed by Croma.Result.get!/1.

read_latest_snapshot_and_logs_if_available(dir)

@spec read_latest_snapshot_and_logs_if_available(Path.t()) ::
  nil
  | {t(), RaftedValue.Persistence.SnapshotMetadata.t(),
     Enumerable.t(RaftedValue.LogEntry.t())}

term(snapshot)

@spec term(t()) :: RaftedValue.TermNumber.t()

Type-aware getter for term.

term(s, field)

@spec term(t(), RaftedValue.TermNumber.t()) :: t()

Type-aware setter for term.

update(s, dict)

@spec update(t(), Dict.t()) :: Croma.Result.t(t())

Updates an existing instance of RaftedValue.Snapshot with the given dict. The values in the dict are validated by each field's valid?/1 function. Returns {:ok, valid_struct} or {:error, reason}.

update!(s, dict)

@spec update!(t(), Dict.t()) :: t()

A variant of update/2 which returns t or raise if validation fails. In other words, update/2 followed by Croma.Result.get!/1.

valid?(value)

@spec valid?(term()) :: boolean()

Checks if the given value belongs to t/0 or not.