github.com/lmb/consul@v1.4.1/lib/serf.go (about) 1 package lib 2 3 import ( 4 "github.com/hashicorp/serf/serf" 5 "time" 6 ) 7 8 // SerfDefaultConfig returns a Consul-flavored Serf default configuration, 9 // suitable as a basis for a LAN, WAN, segment, or area. 10 func SerfDefaultConfig() *serf.Config { 11 base := serf.DefaultConfig() 12 13 // This effectively disables the annoying queue depth warnings. 14 base.QueueDepthWarning = 1000000 15 16 // This enables dynamic sizing of the message queue depth based on the 17 // cluster size. 18 base.MinQueueDepth = 4096 19 20 // This gives leaves some time to propagate through the cluster before 21 // we shut down. The value was chosen to be reasonably short, but to 22 // allow a leave to get to over 99.99% of the cluster with 100k nodes 23 // (using https://www.serf.io/docs/internals/simulator.html). 24 base.LeavePropagateDelay = 3 * time.Second 25 26 return base 27 } 28 29 func GetSerfTags(serf *serf.Serf) map[string]string { 30 tags := make(map[string]string) 31 for tag, value := range serf.LocalMember().Tags { 32 tags[tag] = value 33 } 34 35 return tags 36 } 37 38 func UpdateSerfTag(serf *serf.Serf, tag, value string) { 39 tags := GetSerfTags(serf) 40 tags[tag] = value 41 42 serf.SetTags(tags) 43 }