github.com/sym3tri/etcd@v0.2.1-0.20140422215517-a563d82f95d6/server/set_cluster_config_command.go (about)

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