Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultHeartbeatTimeout = 300 * time.Millisecond DefaultElectionTimeout = 300 * time.Millisecond DefaultLeaderLease = 200 * time.Millisecond )
Raft and consensus related parameters.
Variables ¶
View Source
var DefaultConfig = Config{ HeartbeatTimeout: DefaultHeartbeatTimeout, ElectionTimeout: DefaultElectionTimeout, LeaderLease: DefaultLeaderLease, }
DefaultConfig represents the default settings for the raft handler.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Callbacks []FSMProcessFunc // Callback functions to be invoked by the FSM after execution is done. HeartbeatTimeout time.Duration // How often a consensus cluster leader should ping its followers. ElectionTimeout time.Duration // How long does a consensus cluster node wait for a leader before it triggers an election. LeaderLease time.Duration // How long does a leader remain a leader if it cannot contact a quorum of cluster nodes. }
type FSMLogEntry ¶
type FSMProcessFunc ¶
type FSMProcessFunc func(req FSMLogEntry, res execute.Result)
type Option ¶
type Option func(*Config)
Option can be used to set Raft configuration options.
func WithCallbacks ¶
func WithCallbacks(callbacks ...FSMProcessFunc) Option
func WithElectionTimeout ¶
WithElectionTimeout sets the election timeout for the consensus cluster.
func WithHeartbeatTimeout ¶
WithHeartbeatTimeout sets the heartbeat timeout for the consensus cluster.
func WithLeaderLease ¶
WithLeaderLease sets the leader lease for the consensus cluster leader.
type Replica ¶
func New ¶
func New(log zerolog.Logger, host *host.Host, workspace string, requestID string, executor blockless.Executor, peers []peer.ID, options ...Option) (*Replica, error)
New creates a new raft replica, bootstraps the cluster and waits until a first leader is elected. We do this because only after the election the cluster is really operational and ready to process requests.
Click to show internal directories.
Click to hide internal directories.