Class: Kuroko2::Workflow::Engine
- Inherits:
-
Object
- Object
- Kuroko2::Workflow::Engine
- Defined in:
- lib/autoload/kuroko2/workflow/engine.rb
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
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 56 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(token) end end |
#process(token) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 10 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
4 5 6 7 8 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 4 def process_all Token.processable.each do |token| process(token) end end |
#retry(token) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 20 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_column(:error_at, nil) token.job_instance.logs.info() token.mark_as_working token.save! Kuroko2.logger.info() Notifier.notify(:working, token.job_instance) end end |
#skip(token) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/autoload/kuroko2/workflow/engine.rb', line 37 def skip(token) token.with_lock do node = extract_node(token) = "(token #{token.uuid}) Skip current node: '#{node.type}: #{node.option}'" token.job_instance.update_column(:error_at, nil) token.job_instance.logs.info() token.mark_as_working process_next(node.next, token) token.save! unless token.destroyed? Kuroko2.logger.info() Notifier.notify(:working, token.job_instance) end end |