Class: River::InsertOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/insert_opts.rb

Overview

Options for job insertion, and which can be provided by implementing #insert_opts on job args, or specified as a parameter on #insert or #insert_many.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_attempts: nil, priority: nil, queue: nil, scheduled_at: nil, tags: nil, unique_opts: nil) ⇒ InsertOpts

Returns a new instance of InsertOpts.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/insert_opts.rb', line 46

def initialize(
  max_attempts: nil,
  priority: nil,
  queue: nil,
  scheduled_at: nil,
  tags: nil,
  unique_opts: nil
)
  self.max_attempts = max_attempts
  self.priority = priority
  self.queue = queue
  self.scheduled_at = scheduled_at
  self.tags = tags
  self.unique_opts = unique_opts
end

Instance Attribute Details

#max_attemptsObject

The maximum number of total attempts (including both the original run and all retries) before a job is abandoned and set as discarded.



8
9
10
# File 'lib/insert_opts.rb', line 8

def max_attempts
  @max_attempts
end

#priorityObject

The priority of the job, with 1 being the highest priority and 4 being the lowest. When fetching available jobs to work, the highest priority jobs will always be fetched before any lower priority jobs are fetched. Note that if your workers are swamped with more high-priority jobs then they can handle, lower priority jobs may not be fetched.

Defaults to PRIORITY_DEFAULT.



17
18
19
# File 'lib/insert_opts.rb', line 17

def priority
  @priority
end

#queueObject

The name of the job queue in which to insert the job.

Defaults to QUEUE_DEFAULT.



22
23
24
# File 'lib/insert_opts.rb', line 22

def queue
  @queue
end

#scheduled_atObject

A time in future at which to schedule the job (i.e. in cases where it shouldn’t be run immediately). The job is guaranteed not to run before this time, but may run slightly after depending on the number of other scheduled jobs and how busy the queue is.

Use of this option generally only makes sense when passing options into Insert rather than when a job args is returning #insert_opts, however, it will work in both cases.



32
33
34
# File 'lib/insert_opts.rb', line 32

def scheduled_at
  @scheduled_at
end

#tagsObject

An arbitrary list of keywords to add to the job. They have no functional behavior and are meant entirely as a user-specified construct to help group and categorize jobs.

If tags are specified from both a job args override and from options on Insert, the latter takes precedence. Tags are not merged.



40
41
42
# File 'lib/insert_opts.rb', line 40

def tags
  @tags
end

#unique_optsObject

Options relating to job uniqueness. No unique options means that the job is never treated as unique.



44
45
46
# File 'lib/insert_opts.rb', line 44

def unique_opts
  @unique_opts
end