set_cluster_config_command.go 689 B

12345678910111213141516171819202122232425262728
  1. // +build ignore
  2. package server
  3. import (
  4. "github.com/coreos/etcd/third_party/github.com/goraft/raft"
  5. )
  6. func init() {
  7. raft.RegisterCommand(&SetClusterConfigCommand{})
  8. }
  9. // SetClusterConfigCommand sets the cluster-level configuration.
  10. type SetClusterConfigCommand struct {
  11. Config *ClusterConfig `json:"config"`
  12. }
  13. // CommandName returns the name of the command.
  14. func (c *SetClusterConfigCommand) CommandName() string {
  15. return "etcd:setClusterConfig"
  16. }
  17. // Apply updates the cluster configuration.
  18. func (c *SetClusterConfigCommand) Apply(context raft.Context) (interface{}, error) {
  19. ps, _ := context.Server().Context().(*PeerServer)
  20. ps.SetClusterConfig(c.Config)
  21. return nil, nil
  22. }