本文整理匯總了Golang中github.com/goraft/raft.Server.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Server.Name方法的具體用法?Golang Server.Name怎麽用?Golang Server.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/goraft/raft.Server
的用法示例。
在下文中一共展示了Server.Name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Apply
func (dcmd *delCommand) Apply(server raft.Server) (interface{}, error) {
if server.Name() == server.Leader() {
return nil, nil
}
kvs := server.Context().(KVstore)
err := kvs.Delete(dcmd.Key)
return nil, err
}
示例2: Apply
func (c *InfluxChangeConnectionStringCommand) Apply(server raft.Server) (interface{}, error) {
if c.Name == server.Name() {
return nil, nil
}
server.RemovePeer(c.Name)
server.AddPeer(c.Name, c.ConnectionString)
clusterConfig := server.Context().(*cluster.ClusterConfiguration)
newServer := clusterConfig.GetServerByRaftName(c.Name)
// it's a new server the cluster has never seen, make it a potential
if newServer == nil {
return nil, fmt.Errorf("Server %s doesn't exist", c.Name)
}
newServer.RaftConnectionString = c.ConnectionString
newServer.ProtobufConnectionString = c.ProtobufConnectionString
server.Context().(*cluster.ClusterConfiguration).ChangeProtobufConnectionString(newServer)
server.FlushCommitIndex()
return nil, nil
}