View Source RaftedValue.Logs (rafted_value v0.11.2)

Link to this section Summary

Functions

Type-aware getter for followers.

Type-aware setter for followers.

Type-aware getter for i_committed.

Type-aware setter for i_committed.

Type-aware getter for i_max.

Type-aware setter for i_max.

Type-aware getter for i_min.

Type-aware setter for i_min.

Type-aware getter for map.

Type-aware setter for map.

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

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

Updates an existing instance of RaftedValue.Logs 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.Logs{
  followers: Croma.TypeGen.Nilable.RaftedValue.FollowerIndices.t(),
  i_committed: RaftedValue.LogIndex.t(),
  i_max: RaftedValue.LogIndex.t(),
  i_min: RaftedValue.LogIndex.t(),
  map: RaftedValue.LogsMap.t()
}

Link to this section Functions

Link to this function

add_entry(logs, persistence, f)

View Source
Link to this function

add_entry_on_add_follower(logs, term, new_follower, persistence)

View Source
@spec add_entry_on_add_follower(
  t(),
  RaftedValue.TermNumber.t(),
  pid(),
  nil | RaftedValue.Persistence.t()
) :: {t(), RaftedValue.LogEntry.t()}
Link to this function

add_entry_on_elected_leader(logs, members, term, persistence)

View Source
@spec add_entry_on_elected_leader(
  t(),
  RaftedValue.Members.t(),
  RaftedValue.TermNumber.t(),
  nil | RaftedValue.Persistence.t()
) :: {t(), RaftedValue.LogEntry.t()}
Link to this function

add_entry_on_remove_follower(logs, term, follower_to_remove, persistence)

View Source
@spec add_entry_on_remove_follower(
  t(),
  RaftedValue.TermNumber.t(),
  pid(),
  nil | RaftedValue.Persistence.t()
) :: {t(), RaftedValue.LogEntry.t()}
Link to this function

add_entry_on_restored_from_files(logs, term)

View Source
@spec add_entry_on_restored_from_files(t(), RaftedValue.TermNumber.t()) ::
  {t(), RaftedValue.LogEntry.t()}
Link to this function

append_entries(logs, members0, entries, i_leader_commit, persistence)

View Source
Link to this function

candidate_log_up_to_date?(arg0, candidate_log_info)

View Source
@spec candidate_log_up_to_date?(t(), RaftedValue.LogInfo.t()) :: boolean()
Link to this function

commit_to_latest(logs, persistence)

View Source
@spec commit_to_latest(
  t(),
  nil | RaftedValue.Persistence.t()
) :: {t(), [RaftedValue.LogEntry.t()]}
Link to this function

contain_given_prev_log?(arg0, arg1)

View Source
@spec contain_given_prev_log?(
  t(),
  {any(), any()}
) :: boolean()
Link to this function

decrement_next_index_of_follower(logs, follower_pid)

View Source
@spec decrement_next_index_of_follower(
  t(),
  pid()
) :: t()
@spec followers(t()) :: Croma.TypeGen.Nilable.RaftedValue.FollowerIndices.t()

Type-aware getter for followers.

@spec followers(t(), Croma.TypeGen.Nilable.RaftedValue.FollowerIndices.t()) :: t()

Type-aware setter for followers.

@spec i_committed(t()) :: RaftedValue.LogIndex.t()

Type-aware getter for i_committed.

@spec i_committed(t(), RaftedValue.LogIndex.t()) :: t()

Type-aware setter for i_committed.

@spec i_max(t()) :: RaftedValue.LogIndex.t()

Type-aware getter for i_max.

@spec i_max(t(), RaftedValue.LogIndex.t()) :: t()

Type-aware setter for i_max.

@spec i_min(t()) :: RaftedValue.LogIndex.t()

Type-aware getter for i_min.

@spec i_min(t(), RaftedValue.LogIndex.t()) :: t()

Type-aware setter for i_min.

Link to this function

last_committed_entry(arg0)

View Source
@spec last_committed_entry(t()) :: RaftedValue.LogEntry.t()
@spec last_entry(t()) :: RaftedValue.LogEntry.t()
Link to this function

make_append_entries_req(logs, term, follower_pid, now)

View Source
@spec make_append_entries_req(
  t(),
  RaftedValue.TermNumber.t(),
  pid(),
  integer()
) :: {:ok, RaftedValue.RPC.AppendEntriesRequest.t()} | {:too_old, t()} | :error
@spec map(t()) :: RaftedValue.LogsMap.t()

Type-aware getter for map.

@spec map(t(), RaftedValue.LogsMap.t()) :: t()

Type-aware setter for map.

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

Creates a new instance of RaftedValue.Logs 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_for_lonely_leader(last_committed_entry, entries_to_append)

View Source
@spec new_for_lonely_leader(
  RaftedValue.LogEntry.t(),
  Enum.t(RaftedValue.LogEntry.t())
) :: t()
Link to this function

new_for_new_follower(last_committed_entry)

View Source
@spec new_for_new_follower(RaftedValue.LogEntry.t()) :: t()
Link to this function

set_follower_index(logs, arg1, current_term, follower_pid, i_replicated, persistence)

View Source
Link to this function

set_follower_index_as_snapshot_last_index(logs, arg1, follower_pid, arg3)

View Source
@spec set_follower_index_as_snapshot_last_index(
  t(),
  RaftedValue.Members.t(),
  pid(),
  RaftedValue.Persistence.SnapshotMetadata.t()
) :: t()
@spec update(t(), Dict.t()) :: Croma.Result.t(t())

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