func Start(q JobQueue, m *model.Queue) Dispatcher {
	return Config{}.Start(q, m)
}
Start creates and starts a new dispatcher instance with the default
configuration.
package dispatcher
import (
	"context"
	"sync"
	"github.com/fireworq/fireworq/dispatcher/kicker"
	"github.com/fireworq/fireworq/dispatcher/worker"
	"github.com/fireworq/fireworq/jobqueue"
	"github.com/fireworq/fireworq/model"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
	"golang.org/x/time/rate"
)
const defaultMinBufferSize = 1000
func Init() {
	worker.HTTPInit()
}
type Config struct {
	MinBufferSize uint
	Kicker        kicker.Config
	Worker        worker.Config
}
func (cfg Config) Start(q JobQueue, m *model.Queue) Dispatcher {
	logger := log.With().Str("package", "dispatcher").Str("queue", q.Name()).Logger()
	bufferSize := cfg.MinBufferSize
	if bufferSize == 0 {
		bufferSize = defaultMinBufferSize
	}
	if m.MaxWorkers > bufferSize {
		bufferSize = m.MaxWorkers
	}
	kc := cfg.Kicker
	if kc == nil {
		kc = &kicker.PollingKicker{Interval: m.PollingInterval}
	}
	k := kc.NewKicker()
	wc := cfg.Worker
	if wc == nil {
		wc = &worker.HTTPWorker{Logger: &logger}
	}
	w := wc.NewWorker()
	dps := rate.Limit(m.MaxDispatchesPerSecond)
	if dps == 0 {
		dps = rate.Inf
	}
	limiter := rate.NewLimiter(dps, int(m.MaxBurstSize))
	d := &dispatcher{
		jobqueue:  q,
		kicker:    k,
		worker:    w,
		kick:      make(chan struct{}),
		stop:      make(chan struct{}),
		stopped:   make(chan struct{}),
		jobBuffer: make(chan jobqueue.Job, bufferSize),
		sem:       make(chan struct{}, m.MaxWorkers),
		limiter:   limiter,
		logger:    logger,
	}
	go d.loop()
	k.Start(d)
	return d
}
type Dispatcher interface {
	Stats() *Stats
	PollingInterval() uint
	MaxWorkers() uint
	MaxDispatchesPerSecond() float64
	MaxBurstSize() int
	Ping()
	Stop() <-chan struct{}
}