coordinate

module
v4.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2021 License: Apache-2.0

README

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)
	}
})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL