func (eq *Queue) Close() error {
	eq.mu.Lock()
	defer eq.mu.Unlock()
	if eq.closed {
		return nil
	}
	eq.closed = true
	eq.cond.Signal()  
	eq.cond.Wait()    
	return eq.dst.Close()
}
Close shutsdown the event queue, flushing
package events
import (
	"container/list"
	"sync"
	"github.com/sirupsen/logrus"
)
type Queue struct {
	dst    Sink
	events *list.List
	cond   *sync.Cond
	mu     sync.Mutex
	closed bool
}
func NewQueue(dst Sink) *Queue {
	eq := Queue{
		dst:    dst,
		events: list.New(),
	}
	eq.cond = sync.NewCond(&eq.mu)
	go eq.run()
	return &eq
}
func (eq *Queue) Write(event Event) error {
	eq.mu.Lock()
	defer eq.mu.Unlock()
	if eq.closed {
		return ErrSinkClosed
	}
	eq.events.PushBack(event)
	eq.cond.Signal()  
	return nil
}