8000 GitHub - gravitational/coordinate: Set of utilities for ETCD and BoltDB
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

gravitational/coordinate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coordinate

Coordinate provides Etcd-based leader election with backoff and events:

client, err := leader.NewClient(...)
if err != nil {
	return nil, trace.Wrap(err)
}

if err := client.AddVoter(conf.LeaderKey, "my id", conf.Term); err != nil {
	return nil, trace.Wrap(err)
}
// certain units must work only if the node is a master
client.AddWatchCallback(conf.LeaderKey, conf.Term/3, func(key, prevVal, newVal string) {
	if newVal == "my id" {
		log.Infof("i am leader now!")
	} else {
		log.Infof("%v just became a new leader", newVal)
	}
})

About

Set of utilities for ETCD and BoltDB

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

0