Created
February 24, 2017 00:08
-
-
Save iNecas/4ad20c1451f46ef91b198ed5e9fdd413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/dynflow/action/with_bulk_sub_plans.rb b/lib/dynflow/action/with_bulk_sub_plans.rb | |
index dbff3a2..9dae0e2 100644 | |
--- a/lib/dynflow/action/with_bulk_sub_plans.rb | |
+++ b/lib/dynflow/action/with_bulk_sub_plans.rb | |
@@ -9,6 +9,17 @@ module Dynflow | |
raise NotImplementedError | |
end | |
+ PlanNextBatch = Algebrick.atom | |
+ | |
+ def run(event = nil) | |
+ if event === PlanNextBatch | |
+ spawn_plans if can_spawn_next_batch? | |
+ suspend | |
+ else | |
+ super | |
+ end | |
+ end | |
+ | |
# Should return the expected total count of tasks | |
def total_count | |
raise NotImplementedError | |
@@ -40,13 +51,10 @@ module Dynflow | |
end | |
end | |
- def try_to_finish | |
- # Start next batch if we can, try to finish otherwise | |
- if can_spawn_next_batch? | |
- spawn_plans | |
- else | |
- super | |
- end | |
+ def spawn_plans | |
+ super | |
+ ensure | |
+ suspended_action << PlanNextBatch | |
end | |
private | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment