Code Monkey home page Code Monkey logo

efind's Introduction

efind使用简介

efind用于快速对一个etcd节点进行配置,让子节点进行选举,目前暂不支持etcd集群

func New(){
//设置etcd节点名
	client := efind.NewClient(efind.Config{
		EtcdAddr: "127.0.0.1:2379",
		TTL:      5,
	})
    // 按照go.etcd.io/etcd/client/v3/concurrency包的安排,会先指定一个事件
	session, err := client.NewSession()
	if err != nil {
		log.Panicln(err)
		return
	}
    // 选举名和选举内容
	elect := session.NewElect("etcd/user1", *f)
	//fmt.Println("elect.ReturnLeader():", elect.ReturnLeader())
    // 打印当前选举目标的leader
	go elect.LogReturnLeader()
	fmt.Println("elect.Info()", elect.Info())
    // 阻塞进行选举
	err = elect.Campaign()
	if err != nil {
		log.Panicln(err)
		return
	}
    for{
        
    }
}

efind's People

Contributors

llightos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.