func (c *Coordinator) GetHeldLeases() []Lease {
	return c.Renewer.GetHeldLeases()
}
GetHeldLeases returns the currently held leases.
A lease is currently held if we successfully renewed it on the last run of Renewer.Renew().
Lease objects returned are copies and their counters will not tick.
package lease
import "time"
type Coordinator struct {
	*Config
	Manager Manager
	Renewer Renewer
	Taker   Taker
	stopTaker  chan struct{}
	stopRenwer chan struct{}
}
type loopFunc func() error
func New(config *Config) Leaser {
	config.defaults()
	manager := &LeaseManager{config, newSerializer()}
	return &Coordinator{
		Config:  config,
		Manager: manager,
		Renewer: &leaseHolder{
			Config:     config,
			manager:    manager,
			heldLeases: make(map[string]*Lease),
		},
		Taker: &leaseTaker{
			Config:    config,
			manager:   manager,
			allLeases: make(map[string]*Lease),
		},
	}
}
func (c *Coordinator) Start() error {
	if err := c.Manager.CreateLeaseTable(); err != nil {
		return err
	}
	takerIntervalMills := (c.ExpireAfter + c.epsilonMills) * 2
	renewerIntervalMills := c.ExpireAfter/3 - c.epsilonMills
	c.stopTaker = c.loop(c.Taker.Take, takerIntervalMills, "take leases")
	c.stopRenwer = c.loop(c.Renewer.Renew, renewerIntervalMills, "renew leases")
	c.Logger.Infof("Start coordinator with failover time %s, and epsilon %s. "+
		"LeaseCoordinator will renew leases every %s, take leases every %s "+
		"and steal %d lease(s) at a time.",
		c.ExpireAfter,
		c.epsilonMills,
		renewerIntervalMills,
		takerIntervalMills,
		c.MaxLeasesToStealAtOneTime)
	return nil
}
func (c *Coordinator) Stop() {
	c.Logger.Info("stopping coordinator")
	c.stopTaker <- struct{}{}
	<-c.stopTaker
	c.stopRenwer <- struct{}{}
	<-c.stopRenwer
	c.Logger.Info("stopped coordinator")
}