Skip to content

Commit

Permalink
Switch to untracked api where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Sep 6, 2022
1 parent d2ba3fe commit 29f1c1c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/chunked_output_benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main_loop
if output[:current] < input[:limit]
consumed = yield
output[:current] += consumed
plan_event(nil)
plan_event(nil, untracked: true)
suspend
end
end
Expand Down
3 changes: 2 additions & 1 deletion examples/orchestrate.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative 'example_helper'

example_description = <<DESC
Orchestrate Example
===================
Expand All @@ -21,7 +23,6 @@
DESC

require_relative 'example_helper'

module Orchestrate

Expand Down
2 changes: 1 addition & 1 deletion examples/orchestrate_evented.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def run(event = nil)
# do nothing
end),
(on nil do
suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished }
suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished, untracked: true }
end))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dynflow/action/polling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def resume_external_action
end

def suspend_and_ping
plan_event(Poll, poll_interval)
plan_event(Poll, poll_interval, untracked: true)
suspend
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dynflow/action/timeouts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def process_timeout
end

def schedule_timeout(seconds, optional: false)
plan_event(Timeout, seconds, optional: optional)
plan_event(Timeout, seconds, optional: optional, untracked: true)
end
end
end
2 changes: 1 addition & 1 deletion lib/dynflow/action/with_bulk_sub_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run_progress
def spawn_plans
super
ensure
plan_event(PlanNextBatch)
plan_event(PlanNextBatch, untracked: true)
end

def cancel!(force = false)
Expand Down
4 changes: 4 additions & 0 deletions lib/dynflow/action/with_polling_sub_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ def recalculate_counts
:failed_count => failed - output.fetch(:resumed_count, 0),
:success_count => success)
end

def can_fire_and_forget_sub_plans?
true
end
end
end
7 changes: 6 additions & 1 deletion lib/dynflow/action/with_sub_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def trigger(action_class, *args)
if uses_concurrency_control
trigger_with_concurrency_control(action_class, *args)
else
world.trigger { world.plan_with_options(action_class: action_class, args: args, caller_action: self) }
method = can_fire_and_forget_sub_plans? ? :trigger_untracked : :trigger
world.public_send(:trigger) { world.plan_with_options(action_class: action_class, args: args, caller_action: self) }
end
end

Expand Down Expand Up @@ -234,5 +235,9 @@ def check_for_errors!
def uses_concurrency_control
@uses_concurrency_control = input.key? :concurrency_control
end

def can_fire_and_forget_sub_plans?
false
end
end
end

0 comments on commit 29f1c1c

Please sign in to comment.