Class: Dynflow::Actors::ExecutionPlanCleaner::Core
- Inherits:
-
Dynflow::Actor
- Object
- Concurrent::Actor::Context
- Dynflow::Actor
- Dynflow::Actors::ExecutionPlanCleaner::Core
show all
- Defined in:
- lib/dynflow/actors/execution_plan_cleaner.rb
Instance Method Summary
collapse
#behaviour_definition, #finish_termination, #start_termination, #terminating?
#on_message
#log
Constructor Details
#initialize(world, options = {}) ⇒ Core
Returns a new instance of Core.
29
30
31
32
33
34
35
|
# File 'lib/dynflow/actors/execution_plan_cleaner.rb', line 29
def initialize(world, options = {})
@world = world
default_age = 60 * 60 * 24
@poll_interval = options.fetch(:poll_interval, default_age)
@max_age = options.fetch(:max_age, default_age)
start
end
|
Instance Method Details
#clean! ⇒ Object
42
43
44
45
46
|
# File 'lib/dynflow/actors/execution_plan_cleaner.rb', line 42
def clean!
plans = @world.persistence.find_old_execution_plans(Time.now.utc - @max_age)
report(plans)
@world.persistence.delete_execution_plans(uuid: plans.map(&:id))
end
|
#report(plans) ⇒ Object
48
49
50
|
# File 'lib/dynflow/actors/execution_plan_cleaner.rb', line 48
def report(plans)
@world.logger.info("Execution plan cleaner removing #{plans.count} execution plans.")
end
|
#set_clock ⇒ Object
52
53
54
|
# File 'lib/dynflow/actors/execution_plan_cleaner.rb', line 52
def set_clock
@world.clock.ping(self, @poll_interval, :start)
end
|
#start ⇒ Object
37
38
39
40
|
# File 'lib/dynflow/actors/execution_plan_cleaner.rb', line 37
def start
set_clock
clean!
end
|