View Source RaftedValue.Persistence (rafted_value v0.11.2)

Link to this section Summary

Functions

Type-aware getter for dir.

Type-aware setter for dir.

Type-aware getter for latest_snapshot_metadata.

Type-aware setter for latest_snapshot_metadata.

Type-aware getter for log_expansion_factor.

Type-aware setter for log_expansion_factor.

Type-aware getter for log_fd.

Type-aware setter for log_fd.

Type-aware getter for log_size_written.

Type-aware setter for log_size_written.

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

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

Type-aware getter for snapshot_writer.

Type-aware setter for snapshot_writer.

Updates an existing instance of RaftedValue.Persistence 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.

Link to this section Types

@type t() :: %RaftedValue.Persistence{
  dir: Croma.String.t(),
  latest_snapshot_metadata:
    Croma.TypeGen.Nilable.RaftedValue.Persistence.SnapshotMetadata.t(),
  log_expansion_factor: Croma.Number.t(),
  log_fd: Croma.TypeGen.Nilable.Croma.Tuple.t(),
  log_size_written: Croma.NonNegInteger.t(),
  snapshot_writer: Croma.TypeGen.Nilable.Croma.Pid.t()
}

Link to this section Functions

@spec dir(t()) :: Croma.String.t()

Type-aware getter for dir.

@spec dir(t(), Croma.String.t()) :: t()

Type-aware setter for dir.

Link to this function

find_log_files_containing_uncommitted_entries(dir, i_committed)

View Source
@spec find_log_files_containing_uncommitted_entries(
  Path.t(),
  RaftedValue.LogIndex.t()
) :: [Path.t()]
Link to this function

latest_snapshot_metadata(persistence)

View Source
@spec latest_snapshot_metadata(t()) ::
  Croma.TypeGen.Nilable.RaftedValue.Persistence.SnapshotMetadata.t()

Type-aware getter for latest_snapshot_metadata.

Link to this function

latest_snapshot_metadata(s, field)

View Source
@spec latest_snapshot_metadata(
  t(),
  Croma.TypeGen.Nilable.RaftedValue.Persistence.SnapshotMetadata.t()
) ::
  t()

Type-aware setter for latest_snapshot_metadata.

@spec list_snapshots_in(Path.t()) :: [Path.t()]
Link to this function

log_compaction_runnable?(arg0)

View Source
@spec log_compaction_runnable?(t()) :: boolean()
Link to this function

log_expansion_factor(persistence)

View Source
@spec log_expansion_factor(t()) :: Croma.Number.t()

Type-aware getter for log_expansion_factor.

Link to this function

log_expansion_factor(s, field)

View Source
@spec log_expansion_factor(t(), Croma.Number.t()) :: t()

Type-aware setter for log_expansion_factor.

@spec log_fd(t()) :: Croma.TypeGen.Nilable.Croma.Tuple.t()

Type-aware getter for log_fd.

@spec log_fd(t(), Croma.TypeGen.Nilable.Croma.Tuple.t()) :: t()

Type-aware setter for log_fd.

Link to this function

log_size_written(persistence)

View Source
@spec log_size_written(t()) :: Croma.NonNegInteger.t()

Type-aware getter for log_size_written.

Link to this function

log_size_written(s, field)

View Source
@spec log_size_written(t(), Croma.NonNegInteger.t()) :: t()

Type-aware setter for log_size_written.

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

Creates a new instance of RaftedValue.Persistence 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.

@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.

Link to this function

new_with_disk_snapshot(dir, factor, meta, entry_restore)

View Source
@spec new_with_disk_snapshot(
  Path.t(),
  number(),
  RaftedValue.Persistence.SnapshotMetadata.t(),
  RaftedValue.LogEntry.t()
) :: t()
Link to this function

new_with_initial_snapshotting(dir, factor, snapshot)

View Source
@spec new_with_initial_snapshotting(Path.t(), number(), RaftedValue.Snapshot.t()) ::
  t()
Link to this function

new_with_snapshot_sent_from_leader(dir, factor, snapshot)

View Source
@spec new_with_snapshot_sent_from_leader(Path.t(), number(), RaftedValue.Snapshot.t()) ::
  t()
Link to this function

read_last_log_index(dir)

View Source
@spec read_last_log_index(Path.t()) :: nil | RaftedValue.LogIndex.t()
Link to this function

snapshot_writer(persistence)

View Source
@spec snapshot_writer(t()) :: Croma.TypeGen.Nilable.Croma.Pid.t()

Type-aware getter for snapshot_writer.

Link to this function

snapshot_writer(s, field)

View Source
@spec snapshot_writer(t(), Croma.TypeGen.Nilable.Croma.Pid.t()) :: t()

Type-aware setter for snapshot_writer.

Link to this function

switch_log_file_and_spawn_snapshot_writer(persistence, snapshot, index_next)

View Source
@spec switch_log_file_and_spawn_snapshot_writer(
  t(),
  RaftedValue.Snapshot.t(),
  RaftedValue.LogIndex.t()
) :: t()
Link to this function

unset_snapshot_metadata(p)

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

Updates an existing instance of RaftedValue.Persistence 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}.

@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.

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

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

Link to this function

write_log_entries(p, entries)

View Source
@spec write_log_entries(t(), [RaftedValue.LogEntry.t()]) :: t()