View Source RaftedValue.Election (rafted_value v0.11.2)
Link to this section 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.
Link to this section Types
@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()
}
Link to this section Functions
@spec gain_vote(t(), RaftedValue.Members.t(), pid()) :: {t(), boolean()}
@spec leader_message_at(t()) :: Croma.TypeGen.Nilable.RaftedValue.Monotonic.t()
Type-aware getter for leader_message_at.
Type-aware setter for leader_message_at.
@spec minimum_timeout_elapsed_since_last_leader_message?(t(), RaftedValue.Config.t()) :: boolean()
@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
.
A variant of new/1
which returns t
or raise if validation fails.
In other words, new/1
followed by Croma.Result.get!/1
.
@spec new_for_follower(RaftedValue.Config.t()) :: t()
@spec new_for_leader() :: t()
@spec reset_timer(t(), RaftedValue.Config.t()) :: t()
@spec timer(t()) :: Croma.TypeGen.Nilable.Croma.Reference.t()
Type-aware getter for timer.
Type-aware setter for timer.
@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}
.
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 update_for_candidate(t(), RaftedValue.Config.t()) :: t()
@spec update_for_follower(t(), RaftedValue.Config.t()) :: t()
Checks if the given value belongs to t/0
or not.
@spec vote_for(t(), pid(), RaftedValue.Config.t()) :: t()
@spec voted_for(t()) :: Croma.TypeGen.Nilable.Croma.Pid.t()
Type-aware getter for voted_for.
Type-aware setter for voted_for.
@spec votes(t()) :: Croma.TypeGen.Nilable.RaftedValue.PidSet.t()
Type-aware getter for votes.
Type-aware setter for votes.