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.
This commit is contained in:
Matt Jaffee 2017-04-18 11:18:43 -05:00 committed by Travis
parent 6e8bf5dcc1
commit 0da580d0e9
3 changed files with 9 additions and 10 deletions

View file

@ -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.")

View file

@ -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)

View file

@ -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.