From 0da580d0e902e34671ffcff2de613bced9d7e749 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 18 Apr 2017 11:18:43 -0500 Subject: [PATCH] change broadcaster-type to type It is nested under "cluster" in the config, and it controls cluster membership as well as broadcasting, so I think type is more appropriate. Also, brevity. --- cmd/server.go | 2 +- config.go | 12 ++++++------ server/server.go | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index e9d7fcfdf..2dd662bbe 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -83,7 +83,7 @@ on the configured port.`, flags.DurationVarP((*time.Duration)(&Server.Config.AntiEntropy.Interval), "anti-entropy.interval", "", time.Minute*10, "Interval at which to run anti-entropy routine.") flags.StringVarP(&Server.CPUProfile, "profile.cpu", "", "", "Where to store CPU profile.") flags.DurationVarP(&Server.CPUTime, "profile.cpu-time", "", 30*time.Second, "CPU profile duration.") - flags.StringVarP(&Server.Config.Cluster.BroadcasterType, "cluster.broadcaster-type", "", "static", "Type of Broadcaster to use for inter-host messaging. Choose from [static, http, gossip]") + flags.StringVarP(&Server.Config.Cluster.Type, "cluster.type", "", "static", "Determine how the cluster handles membership and state sharing. Choose from [static, http, gossip]") flags.StringVarP(&Server.Config.Cluster.Gossip.Seed, "cluster.gossip.seed", "", "", "Host with which to seed the gossip membership.") flags.IntVarP(&Server.Config.Cluster.Gossip.Port, "cluster.gossip.port", "", 0, "Port to which pilosa should bind for gossip.") diff --git a/config.go b/config.go index 8b718f4e1..094bb9d65 100644 --- a/config.go +++ b/config.go @@ -4,10 +4,10 @@ import "time" const ( // DefaultHost is the default hostname and port to use. - DefaultHost = "localhost" - DefaultPort = "10101" - DefaultBroadcasterType = "static" - DefaultGossipPort = "14000" + DefaultHost = "localhost" + DefaultPort = "10101" + DefaultClusterType = "static" + DefaultGossipPort = "14000" ) // Config represents the configuration for the command. @@ -17,7 +17,7 @@ type Config struct { Cluster struct { ReplicaN int `toml:"replicas"` - BroadcasterType string `toml:"broadcaster-type"` + Type string `toml:"type"` Nodes []string `toml:"hosts"` PollingInterval Duration `toml:"polling-interval"` Gossip ConfigGossip `toml:"gossip"` @@ -45,7 +45,7 @@ func NewConfig() *Config { Host: DefaultHost + ":" + DefaultPort, } c.Cluster.ReplicaN = DefaultReplicaN - c.Cluster.BroadcasterType = DefaultBroadcasterType + c.Cluster.Type = DefaultClusterType c.Cluster.PollingInterval = Duration(DefaultPollingInterval) c.Cluster.Nodes = []string{} c.AntiEntropy.Interval = Duration(DefaultAntiEntropyInterval) diff --git a/server/server.go b/server/server.go index 3571dcf3c..16d17407f 100644 --- a/server/server.go +++ b/server/server.go @@ -114,14 +114,13 @@ func (m *Command) SetupServer() error { m.Server.Index.Path = m.Config.DataDir m.Server.Index.Stats = pilosa.NewExpvarStatsClient() - // Build cluster from config file. var err error m.Server.Host, err = normalizeHost(m.Config.Host) if err != nil { return err } - switch m.Config.Cluster.BroadcasterType { // TODO change name to something that encompasses broadcasting, receiving broadcasts, and tracking cluster membership + switch m.Config.Cluster.Type { // TODO change name to something that encompasses broadcasting, receiving broadcasts, and tracking cluster membership case "http": port := strconv.Itoa(m.Config.Cluster.Gossip.Port) m.Server.Broadcaster = httpbroadcast.NewHTTPBroadcaster(m.Server, port) @@ -157,7 +156,7 @@ func (m *Command) SetupServer() error { m.Server.Cluster.NodeSet = pilosa.NewStaticNodeSet() m.Server.BroadcastReceiver = pilosa.NopBroadcastReceiver default: - return fmt.Errorf("'%v' is not a supported value for broadcaster type.", m.Config.Cluster.BroadcasterType) + return fmt.Errorf("'%v' is not a supported value for broadcaster type.", m.Config.Cluster.Type) } // Set configuration options.