types

package
v0.0.0-...-5f469b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Configuration{
	RequestBatchMaxCount:          100,
	RequestBatchMaxBytes:          10 * 1024 * 1024,
	RequestBatchMaxInterval:       50 * time.Millisecond,
	IncomingMessageBufferSize:     200,
	RequestPoolSize:               400,
	RequestForwardTimeout:         2 * time.Second,
	RequestComplainTimeout:        20 * time.Second,
	RequestAutoRemoveTimeout:      3 * time.Minute,
	ViewChangeResendInterval:      5 * time.Second,
	ViewChangeTimeout:             20 * time.Second,
	LeaderHeartbeatTimeout:        time.Minute,
	LeaderHeartbeatCount:          10,
	NumOfTicksBehindBeforeSyncing: 10,
	CollectTimeout:                time.Second,
	SyncOnStart:                   false,
	SpeedUpViewChange:             false,
	LeaderRotation:                true,
	DecisionsPerLeader:            3,
	RequestMaxBytes:               10 * 1024,
	RequestPoolSubmitTimeout:      5 * time.Second,
}

DefaultConfig contains reasonable values for a small cluster that resides on the same geography (or "Region"), but possibly on different availability zones within the geography. It is assumed that the typical latency between nodes, and between clients to nodes, is approximately 10ms. Set the SelfID.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	// contains filtered or unexported fields
}

func (*Checkpoint) Get

func (*Checkpoint) Set

func (c *Checkpoint) Set(proposal Proposal, signatures []Signature)

type Configuration

type Configuration struct {
	// SelfID is the identifier of the node.
	SelfID uint64

	// RequestBatchMaxCount is the maximal number of requests in a batch.
	// A request batch that reaches this count is proposed immediately.
	RequestBatchMaxCount uint64
	// RequestBatchMaxBytes is the maximal total size of requests in a batch, in bytes.
	// This is also the maximal size of a request. A request batch that reaches this size is proposed immediately.
	RequestBatchMaxBytes uint64
	// RequestBatchMaxInterval is the maximal time interval a request batch is waiting before it is proposed.
	// A request batch is accumulating requests until RequestBatchMaxInterval had elapsed from the time the batch was
	// first created (i.e. the time the first request was added to it), or until it is of count RequestBatchMaxCount,
	// or total size RequestBatchMaxBytes, which ever happens first.
	RequestBatchMaxInterval time.Duration

	// IncomingMessageBufferSize is the size of the buffer holding incoming messages before they are processed.
	IncomingMessageBufferSize uint64
	// RequestPoolSize is the number of pending requests retained by the node.
	// The RequestPoolSize is recommended to be at least double (x2) the RequestBatchMaxCount.
	RequestPoolSize uint64

	// RequestForwardTimeout is started from the moment a request is submitted, and defines the interval after which a
	// request is forwarded to the leader.
	RequestForwardTimeout time.Duration
	// RequestComplainTimeout is started when RequestForwardTimeout expires, and defines the interval after which the
	// node complains about the view leader.
	RequestComplainTimeout time.Duration
	// RequestAutoRemoveTimeout is started when RequestComplainTimeout expires, and defines the interval after which
	// a request is removed (dropped) from the request pool.
	RequestAutoRemoveTimeout time.Duration

	// ViewChangeResendInterval defined the interval in which the ViewChange message is resent.
	ViewChangeResendInterval time.Duration
	// ViewChangeTimeout is started when a node first receives a quorum of ViewChange messages, and defines the
	// interval after which the node will try to initiate a view change with a higher view number.
	ViewChangeTimeout time.Duration

	// LeaderHeartbeatTimeout is the interval after which, if nodes do not receive a "sign of life" from the leader,
	// they complain on the current leader and try to initiate a view change. A sign of life is either a heartbeat
	// or a message from the leader.
	LeaderHeartbeatTimeout time.Duration
	// LeaderHeartbeatCount is the number of heartbeats per LeaderHeartbeatTimeout that the leader should emit.
	// The heartbeat-interval is equal to: LeaderHeartbeatTimeout/LeaderHeartbeatCount.
	LeaderHeartbeatCount uint64
	// NumOfTicksBehindBeforeSyncing is the number of follower ticks where the follower is behind the leader
	// by one sequence before starting a sync
	NumOfTicksBehindBeforeSyncing uint64

	// CollectTimeout is the interval after which the node stops listening to StateTransferResponse messages,
	// stops collecting information about view metadata from remote nodes.
	CollectTimeout time.Duration

	// SyncOnStart is a flag indicating whether a sync is required on startup.
	SyncOnStart bool

	// SpeedUpViewChange is a flag indicating whether a node waits for only f+1 view change messages to join
	// the view change (hence speeds up the view change process), or it waits for a quorum before joining.
	// Waiting only for f+1 is considered less safe.
	SpeedUpViewChange bool

	// LeaderRotation is a flag indicating whether leader rotation is active.
	LeaderRotation bool
	// DecisionsPerLeader is the number of decisions reached by a leader before there is a leader rotation.
	DecisionsPerLeader uint64

	// RequestMaxBytes total allowed size of the single request
	RequestMaxBytes uint64

	// RequestPoolSubmitTimeout the total amount of time client can wait for submission of single
	// request into request pool
	RequestPoolSubmitTimeout time.Duration
}

Configuration defines the parameters needed in order to create an instance of Consensus.

func (Configuration) Validate

func (c Configuration) Validate() error

type Decision

type Decision struct {
	Proposal   Proposal
	Signatures []Signature
}

type Proposal

type Proposal struct {
	Payload              []byte
	Header               []byte
	Metadata             []byte
	VerificationSequence int64 // int64 for asn1 marshaling
}

func (Proposal) Digest

func (p Proposal) Digest() string

type Reconfig

type Reconfig struct {
	InLatestDecision bool
	CurrentNodes     []uint64
	CurrentConfig    Configuration
}

type ReconfigSync

type ReconfigSync struct {
	InReplicatedDecisions bool
	CurrentNodes          []uint64
	CurrentConfig         Configuration
}

type RequestInfo

type RequestInfo struct {
	ClientID string
	ID       string
}

func (*RequestInfo) String

func (r *RequestInfo) String() string

type Signature

type Signature struct {
	ID    uint64
	Value []byte
	Msg   []byte
}

type SyncResponse

type SyncResponse struct {
	Latest   Decision
	Reconfig ReconfigSync
}

type ViewAndSeq

type ViewAndSeq struct {
	View uint64
	Seq  uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL