Moves Serf helper into lib to fix import cycle in consul-enterprise.

pull/3735/head
James Phillips 2017-12-07 16:57:58 -08:00
parent b1e45a8e89
commit d12e81860f
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
2 changed files with 23 additions and 17 deletions

View File

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/tlsutil"
"github.com/hashicorp/consul/types" "github.com/hashicorp/consul/types"
"github.com/hashicorp/consul/version" "github.com/hashicorp/consul/version"
@ -376,21 +377,6 @@ func (c *Config) CheckACL() error {
return nil return nil
} }
// 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
return base
}
// DefaultConfig returns a sane default configuration. // DefaultConfig returns a sane default configuration.
func DefaultConfig() *Config { func DefaultConfig() *Config {
hostname, err := os.Hostname() hostname, err := os.Hostname()
@ -404,8 +390,8 @@ func DefaultConfig() *Config {
NodeName: hostname, NodeName: hostname,
RPCAddr: DefaultRPCAddr, RPCAddr: DefaultRPCAddr,
RaftConfig: raft.DefaultConfig(), RaftConfig: raft.DefaultConfig(),
SerfLANConfig: SerfDefaultConfig(), SerfLANConfig: lib.SerfDefaultConfig(),
SerfWANConfig: SerfDefaultConfig(), SerfWANConfig: lib.SerfDefaultConfig(),
SerfFloodInterval: 60 * time.Second, SerfFloodInterval: 60 * time.Second,
ReconcileInterval: 60 * time.Second, ReconcileInterval: 60 * time.Second,
ProtocolVersion: ProtocolVersion2Compatible, ProtocolVersion: ProtocolVersion2Compatible,

20
lib/serf.go Normal file
View File

@ -0,0 +1,20 @@
package lib
import (
"github.com/hashicorp/serf/serf"
)
// 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
return base
}