set_cluster_config_command.go 671 B

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