Class: Kuroko2::Workflow::Task::Queue

Inherits:
Base
  • Object
show all
Defined in:
lib/autoload/kuroko2/workflow/task/queue.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Kuroko2::Workflow::Task::Base

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
# File 'lib/autoload/kuroko2/workflow/task/queue.rb', line 5

def execute
  if option.present?
    token.context['QUEUE'] = option
  else
    token.context['QUEUE'] = Execution::DEFAULT_QUEUE
  end

  :next
end

#validateObject



15
16
17
18
19
20
21
22
23
# File 'lib/autoload/kuroko2/workflow/task/queue.rb', line 15

def validate
  unless /\A[\w_-]{1,180}\z/ === option
    raise Workflow::AssertionError, "Queue name must be match with /\A[\w_-]{1,255}\z/: #{option}"
  end

  unless Worker.where(queue: option, working: true).exists?
    raise Workflow::AssertionError, "No such queue : #{option}"
  end
end