RaftedValue.Election (rafted_value v0.12.0)

Copy Markdown View Source

Summary

Functions

Type-aware getter for leader_message_at.

Type-aware setter for leader_message_at.

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

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

Type-aware getter for timer.

Type-aware setter for timer.

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

Type-aware getter for voted_for.

Type-aware setter for voted_for.

Type-aware getter for votes.

Type-aware setter for votes.

Types

t()

@type t() :: %RaftedValue.Election{
  leader_message_at: Croma.TypeGen.Nilable.RaftedValue.Monotonic.t(),
  timer: Croma.TypeGen.Nilable.Croma.Reference.t(),
  voted_for: Croma.TypeGen.Nilable.Croma.Pid.t(),
  votes: Croma.TypeGen.Nilable.RaftedValue.PidSet.t()
}

Functions

gain_vote(e, arg1, voter)

@spec gain_vote(t(), RaftedValue.Members.t(), pid()) :: {t(), boolean()}

leader_message_at(election)

@spec leader_message_at(t()) :: Croma.TypeGen.Nilable.RaftedValue.Monotonic.t()

Type-aware getter for leader_message_at.

leader_message_at(s, field)

@spec leader_message_at(t(), Croma.TypeGen.Nilable.RaftedValue.Monotonic.t()) :: t()

Type-aware setter for leader_message_at.

minimum_timeout_elapsed_since_last_leader_message?(arg0, arg1)

@spec minimum_timeout_elapsed_since_last_leader_message?(t(), RaftedValue.Config.t()) ::
  boolean()

new(dict)

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

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

new_for_follower(config)

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

new_for_leader()

@spec new_for_leader() :: t()

reset_timer(e, config)

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

timer(election)

@spec timer(t()) :: Croma.TypeGen.Nilable.Croma.Reference.t()

Type-aware getter for timer.

timer(s, field)

@spec timer(t(), Croma.TypeGen.Nilable.Croma.Reference.t()) :: t()

Type-aware setter for timer.

update(s, dict)

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

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

update_for_candidate(e, config)

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

update_for_follower(e, config)

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

valid?(value)

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

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

vote_for(e, candidate, config)

@spec vote_for(t(), pid(), RaftedValue.Config.t()) :: t()

voted_for(election)

@spec voted_for(t()) :: Croma.TypeGen.Nilable.Croma.Pid.t()

Type-aware getter for voted_for.

voted_for(s, field)

@spec voted_for(t(), Croma.TypeGen.Nilable.Croma.Pid.t()) :: t()

Type-aware setter for voted_for.

votes(election)

@spec votes(t()) :: Croma.TypeGen.Nilable.RaftedValue.PidSet.t()

Type-aware getter for votes.

votes(s, field)

@spec votes(t(), Croma.TypeGen.Nilable.RaftedValue.PidSet.t()) :: t()

Type-aware setter for votes.