当前位置: 首页>>代码示例>>Golang>>正文


Golang ConfChange.ID方法代码示例

本文整理汇总了Golang中github.com/coreos/etcd/raft/raftpb.ConfChange.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang ConfChange.ID方法的具体用法?Golang ConfChange.ID怎么用?Golang ConfChange.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coreos/etcd/raft/raftpb.ConfChange的用法示例。


在下文中一共展示了ConfChange.ID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: configure

// configure sends a configuration change through consensus and
// then waits for it to be applied to the server. It will block
// until the change is performed or there is an error.
func (n *Node) configure(ctx context.Context, cc raftpb.ConfChange) error {
	cc.ID = n.reqIDGen.Next()

	ctx, cancel := context.WithCancel(ctx)
	ch := n.wait.register(cc.ID, nil, cancel)

	if err := n.raftNode.ProposeConfChange(ctx, cc); err != nil {
		n.wait.cancel(cc.ID)
		return err
	}

	select {
	case x := <-ch:
		if err, ok := x.(error); ok {
			return err
		}
		if x != nil {
			log.G(ctx).Panic("raft: configuration change error, return type should always be error")
		}
		return nil
	case <-ctx.Done():
		n.wait.cancel(cc.ID)
		return ctx.Err()
	}
}
开发者ID:Mic92,项目名称:docker,代码行数:28,代码来源:raft.go

示例2: configure

// configure sends a configuration change through consensus and
// then waits for it to be applied to the server. It
// will block until the change is performed or there is an error.
func (r *raftNode) configure(ctx context.Context, cc raftpb.ConfChange) error {
	cc.ID = r.idgen.Next()
	ch := r.w.Register(cc.ID)
	start := time.Now()
	if err := r.ProposeConfChange(ctx, cc); err != nil {
		// if err := r.node.ProposeConfChange(ctx, cc); err != nil {
		r.w.Trigger(cc.ID, nil)
		return err
	}
	select {
	case x := <-ch:
		if err, ok := x.(error); ok {
			return err
		}
		if x != nil {
			return fmt.Errorf("return type should always be error")
		}
		return nil
	case <-ctx.Done():
		r.w.Trigger(cc.ID, nil) // GC wait
		return r.parseProposeCtxErr(ctx.Err(), start)
	case <-r.done:
		return raft.ErrStopped
	}
}
开发者ID:blacklabeldata,项目名称:raftor,代码行数:28,代码来源:raft.go

示例3: configure

// configure sends a configuration change through consensus and
// then waits for it to be applied to the server. It will block
// until the change is performed or there is an error.
func (n *Node) configure(ctx context.Context, cc raftpb.ConfChange) error {
	cc.ID = n.reqIDGen.Next()
	ch := n.wait.register(cc.ID, nil)

	if err := n.ProposeConfChange(ctx, cc); err != nil {
		n.wait.trigger(cc.ID, nil)
		return err
	}

	select {
	case x := <-ch:
		if err, ok := x.(error); ok {
			return err
		}
		if x != nil {
			log.G(ctx).Panic("raft: configuration change error, return type should always be error")
		}
		return nil
	case <-ctx.Done():
		n.wait.trigger(cc.ID, nil)
		return ctx.Err()
	case <-n.stopCh:
		return ErrStopped
	}
}
开发者ID:amitshukla,项目名称:docker,代码行数:28,代码来源:raft.go

示例4: configure

// configure sends a configuration change through consensus and
// then waits for it to be applied to the server. It
// will block until the change is performed or there is an error.
func (s *EtcdServer) configure(ctx context.Context, cc raftpb.ConfChange) error {
	cc.ID = s.reqIDGen.Next()
	ch := s.w.Register(cc.ID)
	if err := s.r.ProposeConfChange(ctx, cc); err != nil {
		s.w.Trigger(cc.ID, nil)
		return err
	}
	select {
	case x := <-ch:
		if err, ok := x.(error); ok {
			return err
		}
		if x != nil {
			plog.Panicf("return type should always be error")
		}
		return nil
	case <-ctx.Done():
		s.w.Trigger(cc.ID, nil) // GC wait
		return parseCtxErr(ctx.Err())
	case <-s.done:
		return ErrStopped
	}
}
开发者ID:johnchengliu,项目名称:etcd,代码行数:26,代码来源:server.go


注:本文中的github.com/coreos/etcd/raft/raftpb.ConfChange.ID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。