本文整理汇总了Golang中github.com/coreos/etcd/raft.StartMultiNode函数的典型用法代码示例。如果您正苦于以下问题:Golang StartMultiNode函数的具体用法?Golang StartMultiNode怎么用?Golang StartMultiNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartMultiNode函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewMultiRaft
// NewMultiRaft creates a MultiRaft object.
func NewMultiRaft(nodeID roachpb.NodeID, storeID roachpb.StoreID, config *Config, stopper *stop.Stopper) (*MultiRaft, error) {
if nodeID <= 0 {
return nil, util.Errorf("invalid NodeID: %s", nodeID)
}
if storeID <= 0 {
return nil, util.Errorf("invalid StoreID: %s", storeID)
}
if err := config.validate(); err != nil {
return nil, err
}
if config.Ticker == nil {
config.Ticker = newTicker(config.TickInterval)
stopper.AddCloser(config.Ticker)
}
if config.EntryFormatter != nil {
// Wrap the EntryFormatter to strip off the command id.
ef := config.EntryFormatter
config.EntryFormatter = func(data []byte) string {
if len(data) == 0 {
return "[empty]"
}
id, cmd := decodeCommand(data)
formatted := ef(cmd)
return fmt.Sprintf("%x: %s", id, formatted)
}
}
m := &MultiRaft{
Config: *config,
stopper: stopper,
multiNode: raft.StartMultiNode(0),
nodeID: nodeID,
storeID: storeID,
// Output channel.
Events: make(chan []interface{}),
// Input channels.
reqChan: make(chan *RaftMessageRequest, reqBufferSize),
createGroupChan: make(chan *createGroupOp),
removeGroupChan: make(chan *removeGroupOp),
proposalChan: make(chan *proposal),
callbackChan: make(chan func()),
}
if err := m.Transport.Listen(storeID, (*multiraftServer)(m)); err != nil {
return nil, err
}
return m, nil
}
开发者ID:ruo91,项目名称:cockroach,代码行数:54,代码来源:multiraft.go
示例2: startMultiNode
func startMultiNode(id uint64, nt *multiraftNetwork) *multinode {
st := raft.NewMemoryStorage()
n := &multinode{
MultiNode: raft.StartMultiNode(0),
nodeid: id,
storage: st,
pausec: make(chan bool),
createGroupChan: make(chan createGroupOp),
removeGroupChan: make(chan removeGroupOp),
network: nt,
}
n.start()
return n
}
开发者ID:davygeek,项目名称:rafttest,代码行数:15,代码来源:multinode.go
示例3: NewMultiRaft
// NewMultiRaft creates a MultiRaft object.
func NewMultiRaft(nodeID NodeID, config *Config) (*MultiRaft, error) {
if nodeID == 0 {
return nil, util.Error("Invalid NodeID")
}
err := config.validate()
if err != nil {
return nil, err
}
if config.Ticker == nil {
config.Ticker = newTicker(config.TickInterval)
}
if config.EntryFormatter != nil {
// Wrap the EntryFormatter to strip off the command id.
ef := config.EntryFormatter
config.EntryFormatter = func(data []byte) string {
if len(data) == 0 {
return "[empty]"
}
id, cmd := decodeCommand(data)
formatted := ef(cmd)
return fmt.Sprintf("%x: %s", id, formatted)
}
}
m := &MultiRaft{
Config: *config,
multiNode: raft.StartMultiNode(uint64(nodeID), config.ElectionTimeoutTicks,
config.HeartbeatIntervalTicks),
nodeID: nodeID,
Events: make(chan interface{}, 1000),
reqChan: make(chan *RaftMessageRequest, 100),
createGroupChan: make(chan *createGroupOp, 100),
removeGroupChan: make(chan *removeGroupOp, 100),
proposalChan: make(chan *proposal, 100),
callbackChan: make(chan func(), 100),
stopper: util.NewStopper(1),
}
err = m.Transport.Listen(nodeID, (*multiraftServer)(m))
if err != nil {
return nil, err
}
return m, nil
}
开发者ID:josephwinston,项目名称:cockroach,代码行数:48,代码来源:multiraft.go
注:本文中的github.com/coreos/etcd/raft.StartMultiNode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论