Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrJobEmptyQueue = errors.New("sidekiq: empty job queue") ErrJobEmptyClass = errors.New("sidekiq: empty job class") ErrJobEmptyID = errors.New("sidekiq: empty job id") ErrJobCreatedAt = errors.New("sidekiq: job created_at should be > 0") ErrJobEnqueuedAt = errors.New("sidekiq: job enqueued_at should be > 0") ErrJobArgs = errors.New("sidekiq: job args should be an array") )
sidekiq job validation errors
var ( ErrPullExpireInSec = errors.New("sidekiq: expire-in sec should be > 0") ErrPullRefreshInSec = errors.New("sidekiq: refresh-in sec should be > 0") ErrPullMaxJobs = errors.New("sidekiq: max jobs should be > 0") )
pull validation errors
var (
ErrInvalidQueueID = errors.New("sidekiq: queue id should have format: SIDEKIQ_QUEUE/SIDEKIQ_CLASS")
)
sidekiq queue id validation errors
Functions ¶
func FormatQueueID ¶ added in v0.1.11
FormatQueueID formats sidekiq queue and class.
Types ¶
type JobPuller ¶ added in v0.1.11
type JobPuller interface {
Pull(*PullOptions) error
}
JobPuller pulls jobs from sidekiq-compatible queue.
type PullOptions ¶ added in v0.1.11
type PullOptions struct {
// work-compatible namespace
Namespace string
// optional work-compatible queue
// This allows moving jobs to another redis instance. Without this, these jobs are moved
// within the same sidekiq redis instance.
Queue work.Queue
// sidekiq-compatible namespace
// Only used by https://github.com/resque/redis-namespace. By default, it is empty.
SidekiqNamespace string
// sidekiq-compatible queue like `default`.
SidekiqQueue string
// ExpireInSec controls how long puller expires.
ExpireInSec int64
// RefreshInSec controls how often job ExpireInSec is refreshed.
RefreshInSec int64
// MaxJobs controls how many jobs is pulled at once.
MaxJobs int64
}
PullOptions specifies how a job is pulled from sidekiq-compatible queue.
func (*PullOptions) Validate ¶ added in v0.1.11
func (opt *PullOptions) Validate() error
Validate validates PullOptions.
type Queue ¶ added in v0.1.11
type Queue interface {
work.RedisQueue
JobPuller
work.ExternalEnqueuer
work.ExternalBulkEnqueuer
// contains filtered or unexported methods
}
Queue extends RedisQueue, and allows job pulling from sidekiq-compatible queue.
func NewQueue ¶
func NewQueue(client redis.UniversalClient) Queue
NewQueue creates a new queue stored in redis with sidekiq-compatible format.
This assumes that there is another sidekiq instance that is already running, which moves scheduled jobs into corresponding queues. https://github.com/mperham/sidekiq/blob/e3839682a3d219b8a3708feab607c74241bc06b8/lib/sidekiq/scheduled.rb#L12
Enqueued jobs are directly placed on the scheduled job queues. Dequeued jobs are moved to work-compatible queue as soon as they can run immediately.