Class: Kuroko2::Workflow::Engine
- Inherits:
-
Object
- Object
- Kuroko2::Workflow::Engine
- Defined in:
- lib/autoload/kuroko2/workflow/engine.rb
Constant Summary collapse
- DEFAULT_EXPECTED_TIME =
24 hours
60 * 24
- EXPECTED_TIME_NOTIFY_REMIND_TERM =
1.hours
Instance Method Summary collapse
- #failure(token) ⇒ Object
- #process(token) ⇒ Object
- #process_all ⇒ Object
- #retry(token) ⇒ Object
- #skip(token) ⇒ Object
Instance Method Details
#failure(token) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 46 def failure(token) = "(token #{token.uuid}) Mark as failure." token.job_instance.logs.error() token.job_instance.touch(:error_at) token.mark_as_failure Kuroko2.logger.info() Notifier.notify(:failure, token.job_instance) if token.context['AUTO_SKIP_ERROR'] skip_with_lock(token) end end |
#process(token) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 13 def process(token) unless token.working? || token.waiting? Kuroko2.logger.info { "(token #{token.uuid}) Skip since current status marked as '#{token.status_name}'." } return end token.with_lock { process_with_lock(token) } end |
#process_all ⇒ Object
7 8 9 10 11 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 7 def process_all Token.processable.each do |token| process(token) end end |
#retry(token) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 23 def retry(token) token.with_lock do node = extract_node(token) = "(token #{token.uuid}) Retry current node: '#{node.type}: #{node.option}'" token.job_instance.update_columns(error_at: nil, retrying: true) token.job_instance.logs.info() token.mark_as_working token.save! Kuroko2.logger.info() Notifier.notify(:retrying, token.job_instance) end end |
#skip(token) ⇒ Object
40 41 42 43 44 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 40 def skip(token) token.with_lock do skip_with_lock(token) end end |