etcd/server/set_cluster_config_command.go

27 lines
671 B
Go
Raw Normal View History

2014-02-19 00:29:18 +04:00
package server
import (
"github.com/coreos/etcd/third_party/github.com/goraft/raft"
2014-02-19 00:29:18 +04:00
)
func init() {
raft.RegisterCommand(&SetClusterConfigCommand{})
}
// SetClusterConfigCommand sets the cluster-level configuration.
type SetClusterConfigCommand struct {
Config *ClusterConfig `json:"config"`
}
// CommandName returns the name of the command.
func (c *SetClusterConfigCommand) CommandName() string {
return "etcd:setClusterConfig"
}
// Apply updates the cluster configuration.
func (c *SetClusterConfigCommand) Apply(context raft.Context) (interface{}, error) {
ps, _ := context.Server().Context().(*PeerServer)
ps.SetClusterConfig(c.Config)
return nil, nil
2014-02-19 00:29:18 +04:00
}