func (opt *JobOptions) Validate() error {
	if opt.MaxExecutionTime <= 0 {
		return ErrMaxExecutionTime
	}
	if opt.IdleWait <= 0 {
		return ErrIdleWait
	}
	if opt.NumGoroutines <= 0 {
		return ErrNumGoroutines
	}
	return nil
}
Validate validates JobOptions.
package work
import (
	"context"
	"errors"
	"fmt"
	"runtime/debug"
	"sync"
	"time"
	"github.com/cenkalti/backoff/v4"
)
type DequeueFunc func(*DequeueOptions) (*Job, error)
type DequeueMiddleware func(DequeueFunc) DequeueFunc
type EnqueueFunc func(*Job, *EnqueueOptions) error
type EnqueueMiddleware func(EnqueueFunc) EnqueueFunc
type HandleFunc func(*Job, *DequeueOptions) error
type ContextHandleFunc func(context.Context, *Job, *DequeueOptions) error
type HandleMiddleware func(HandleFunc) HandleFunc
type BackoffFunc func(*Job, *DequeueOptions) time.Duration
type handler struct {
	QueueID    string
	HandleFunc ContextHandleFunc
	JobOptions JobOptions
}
type WorkerOptions struct {
	Namespace string
	Queue     Queue
	ErrorFunc func(error)
}
type Worker struct {
	opt WorkerOptions
	cancel     func()
	wg         sync.WaitGroup
	handlerMap map[string]handler
}
func NewWorker(opt *WorkerOptions) *Worker {
	return &Worker{
		opt:        *opt,
		handlerMap: make(map[string]handler),
	}
}
type JobOptions struct {
	MaxExecutionTime time.Duration
	IdleWait         time.Duration
	NumGoroutines    int64
	Backoff          BackoffFunc
	DequeueMiddleware []DequeueMiddleware
	HandleMiddleware  []HandleMiddleware
}
func (opt *JobOptions) AddDequeueMiddleware(mw DequeueMiddleware) *JobOptions {
	opt.DequeueMiddleware = append(opt.DequeueMiddleware, mw)
	return opt
}
func (opt *JobOptions) AddHandleMiddleware(mw HandleMiddleware) *JobOptions {
	opt.HandleMiddleware = append(opt.HandleMiddleware, mw)
	return opt
}
var (
	ErrMaxExecutionTime = errors.New("work: max execution time should be > 0")
	ErrNumGoroutines    = errors.New("work: number of goroutines should be > 0")
	ErrIdleWait         = errors.New("work: idle wait should be > 0")
)