Class: Gouda::OnlyQueuesConstraint

Inherits:
Struct
  • Object
show all
Defined in:
lib/gouda/queue_constraints.rb

Overview

Allows execution of jobs only from specified queues For example, if you have a queue named “gpu”, and you run jobs requiring a GPU on this queue, on your worker script running on GPU-equipped machines you could use ‘OnlyQueuesConstraint.new()`

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#queue_namesObject

Returns the value of attribute queue_names

Returns:

  • (Object)

    the current value of queue_names



19
20
21
# File 'lib/gouda/queue_constraints.rb', line 19

def queue_names
  @queue_names
end

Instance Method Details

#to_sqlObject



20
21
22
23
24
25
# File 'lib/gouda/queue_constraints.rb', line 20

def to_sql
  placeholders = (["?"] * queue_names.length).join(",")
  Gouda::Workload.sanitize_sql_array([<<~SQL, *queue_names])
    queue_name IN (#{placeholders})
  SQL
end