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

Link to this function

gain_vote(e, arg1, voter)

View Source
@spec gain_vote(t(), RaftedValue.Members.t(), pid()) :: {t(), boolean()}
Link to this function

leader_message_at(election)

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

Type-aware getter for leader_message_at.

Link to this function

leader_message_at(s, field)

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

Type-aware setter for leader_message_at.

Link to this function

minimum_timeout_elapsed_since_last_leader_message?(arg0, arg1)

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

@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_follower(config)

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

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

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

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

Link to this function

update_for_candidate(e, config)

View Source
@spec update_for_candidate(t(), RaftedValue.Config.t()) :: t()
Link to this function

update_for_follower(e, config)

View Source
@spec update_for_follower(t(), RaftedValue.Config.t()) :: t()
@spec valid?(term()) :: boolean()

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

Link to this function

vote_for(e, candidate, config)

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

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

Type-aware setter for voted_for.

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

Type-aware getter for votes.

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

Type-aware setter for votes.