2017-12-08 00:57:58 +00:00
|
|
|
package lib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/serf/serf"
|
2018-05-04 20:51:55 +00:00
|
|
|
"time"
|
2017-12-08 00:57:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SerfDefaultConfig returns a Consul-flavored Serf default configuration,
|
|
|
|
// suitable as a basis for a LAN, WAN, segment, or area.
|
|
|
|
func SerfDefaultConfig() *serf.Config {
|
|
|
|
base := serf.DefaultConfig()
|
|
|
|
|
|
|
|
// This effectively disables the annoying queue depth warnings.
|
|
|
|
base.QueueDepthWarning = 1000000
|
|
|
|
|
|
|
|
// This enables dynamic sizing of the message queue depth based on the
|
|
|
|
// cluster size.
|
|
|
|
base.MinQueueDepth = 4096
|
|
|
|
|
2018-05-04 20:51:55 +00:00
|
|
|
// This gives leaves some time to propagate through the cluster before
|
|
|
|
// we shut down. The value was chosen to be reasonably short, but to
|
|
|
|
// allow a leave to get to over 99.99% of the cluster with 100k nodes
|
|
|
|
// (using https://www.serf.io/docs/internals/simulator.html).
|
|
|
|
base.LeavePropagateDelay = 3 * time.Second
|
|
|
|
|
2017-12-08 00:57:58 +00:00
|
|
|
return base
|
|
|
|
}
|