lxd/cluster/raft.go
func raftConfig(latency float64) *raft.Config {
	config := raft.DefaultConfig()
	scale := func(duration *time.Duration) {
		*duration = time.Duration((math.Ceil(float64(*duration) * latency)))
	}
	durations := []*time.Duration{
		&config.HeartbeatTimeout,
		&config.ElectionTimeout,
		&config.CommitTimeout,
		&config.LeaderLeaseTimeout,
	}
	for _, duration := range durations {
		scale(duration)
	}

	config.SnapshotThreshold = 1024
	config.TrailingLogs = 512

	return config
}
func raftConfig(latency float64) *raft.Config {
	config := raft.DefaultConfig()
	scale := func(duration *time.Duration) {
		*duration = time.Duration((math.Ceil(float64(*duration) * latency)))
	}
	durations := []*time.Duration{
		&config.HeartbeatTimeout,
		&config.ElectionTimeout,
		&config.CommitTimeout,
		&config.LeaderLeaseTimeout,
	}
	for _, duration := range durations {
		scale(duration)
	}

	config.SnapshotThreshold = 1024
	config.TrailingLogs = 512

	return config
}
func raftConfig ( latency float64 ) * raft . Config { config := raft . DefaultConfig ( ) scale := func ( duration * time . Duration ) { * duration = time . Duration ( ( math . Ceil ( float64 ( * duration ) * latency ) ) ) } durations := [ ] * time . Duration { & config . HeartbeatTimeout , & config . ElectionTimeout , & config . CommitTimeout , & config . LeaderLeaseTimeout , } for _ , duration := range durations { scale ( duration ) } config . SnapshotThreshold = 1024 config . TrailingLogs = 512 return config }
// Create a base raft configuration tweaked for a network with the given latency measure.
Create a base raft configuration tweaked for a network with the given latency measure .