Class: Kuroko2::Workflow::Task::Wait
- Inherits:
-
Base
- Object
- Base
- Kuroko2::Workflow::Task::Wait
show all
- Defined in:
- lib/autoload/kuroko2/workflow/task/wait.rb
Constant Summary
collapse
- PERIODS =
%w(hourly daily weekly monthly)
- OPTION_REGEXP =
%r!(\d+)\s*/\s*(#{PERIODS.join('|')})!
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#execute ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/autoload/kuroko2/workflow/task/wait.rb', line 8
def execute
if token.context['WAIT'].present?
if token.waiting?
process_waiting_job
else
Kuroko2.logger.info { "(token #{token.uuid}) Skip since current status marked as '#{token.status_name}'." }
token.mark_as_waiting
:pass
end
else
token.context['WAIT'] = parse_option(option, start_at: token.job_instance.created_at)
Kuroko2.logger.info { "(token #{token.uuid}) waiting jobs: #{token.context['WAIT']["jobs"]}" }
token.mark_as_waiting
message = "(token #{token.uuid}) Marked as 'waiting' #{node.option}."
token.job_instance.logs.info(message)
Kuroko2.logger.info(message)
token.save!
:pass
end
end
|
#process_waiting_job ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/autoload/kuroko2/workflow/task/wait.rb', line 33
def process_waiting_job
receive_waiting_job_completion!
wait_option = token.context['WAIT']
if wait_option["jobs"].all? { |wait_job| wait_job["received"] }
token.mark_as_working
token.context.delete('WAIT')
token.save!
message = "(token #{token.uuid}) All waiting jobs are finished."
Kuroko2.logger.info(message)
token.job_instance.logs.info(message)
:next
elsif wait_option["timeout"].minutes.since(token.created_at).past?
message = "(token #{token.uuid}) waiting jobs `#{node.option}` timeout."
Kuroko2.logger.error(message)
token.job_instance.logs.error(message)
:failure
else
:pass
end
end
|
#validate ⇒ Object
58
59
60
|
# File 'lib/autoload/kuroko2/workflow/task/wait.rb', line 58
def validate
parse_option(option)
end
|