func (d *Dinghy) Start() error {
	d.logger.Println("starting event loop")
	for {
		d.logger.Println(d.State)
		select {
		case <-d.stopChan:
			d.logger.Println("stopping event loop")
			return nil
		default:
		}
		switch d.State.State() {
		case StateFollower:
			if err := d.follower(); err != nil {
				return err
			}
		case StateCandidate:
			d.candidate()
		case StateLeader:
			if err := d.leader(); err != nil {
				return err
			}
		default:
			return fmt.Errorf("unknown state %d", d.State.State())
		}
	}
}
// Start begins the leader election process.
Start begins the leader election process.
// Start begins the leader election process .
func (d *Dinghy) Start() error {
	d.logger.Println("starting event loop")
	for {
		d.logger.Println(d.State)
		select {
		case <-d.stopChan:
			d.logger.Println("stopping event loop")
			return nil
		default:
		}
		switch d.State.State() {
		case StateFollower:
			if err := d.follower(); err != nil {
				return err
			}
		case StateCandidate:
			d.candidate()
		case StateLeader:
			if err := d.leader(); err != nil {
				return err
			}
		default:
			return fmt.Errorf("unknown state %d", d.State.State())
		}
	}
}
func ( d * Dinghy ) Start ( ) error { d . logger . Println ( " " ) for { d . logger . Println ( d . State ) select { case <- d . stopChan : d . logger . Println ( " " ) return nil default : } switch d . State . State ( ) { case StateFollower : if err := d . follower ( ) ; err != nil { return err } case StateCandidate : d . candidate ( ) case StateLeader : if err := d . leader ( ) ; err != nil { return err } default : return fmt . Errorf ( " " , d . State . State ( ) ) } } }
Start begins the leader election process.
Start begins the leader election process .