dynflow 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.rubocop.yml +11 -5
  4. data/.rubocop_todo.yml +777 -345
  5. data/Gemfile +4 -3
  6. data/Rakefile +1 -0
  7. data/doc/pages/Gemfile +4 -3
  8. data/doc/pages/Rakefile +1 -0
  9. data/doc/pages/plugins/alert_block.rb +1 -0
  10. data/doc/pages/plugins/div_tag.rb +1 -0
  11. data/doc/pages/plugins/graphviz.rb +6 -6
  12. data/doc/pages/plugins/plantuml.rb +2 -3
  13. data/doc/pages/plugins/play.rb +1 -2
  14. data/doc/pages/plugins/tags.rb +2 -8
  15. data/doc/pages/plugins/toc.rb +1 -1
  16. data/dynflow.gemspec +11 -10
  17. data/examples/clock_benchmark.rb +1 -0
  18. data/examples/example_helper.rb +4 -3
  19. data/examples/future_execution.rb +0 -2
  20. data/examples/memory_limit_watcher.rb +8 -8
  21. data/examples/orchestrate.rb +9 -21
  22. data/examples/orchestrate_evented.rb +18 -33
  23. data/examples/remote_executor.rb +13 -14
  24. data/examples/singletons.rb +1 -0
  25. data/examples/sub_plan_concurrency_control.rb +0 -1
  26. data/examples/sub_plans.rb +1 -0
  27. data/examples/sub_plans_v2.rb +1 -0
  28. data/lib/dynflow/action/cancellable.rb +1 -0
  29. data/lib/dynflow/action/format.rb +1 -4
  30. data/lib/dynflow/action/missing.rb +4 -4
  31. data/lib/dynflow/action/polling.rb +2 -3
  32. data/lib/dynflow/action/progress.rb +1 -4
  33. data/lib/dynflow/action/rescue.rb +1 -2
  34. data/lib/dynflow/action/singleton.rb +1 -0
  35. data/lib/dynflow/action/suspended.rb +1 -0
  36. data/lib/dynflow/action/timeouts.rb +2 -1
  37. data/lib/dynflow/action/with_bulk_sub_plans.rb +1 -0
  38. data/lib/dynflow/action/with_polling_sub_plans.rb +1 -1
  39. data/lib/dynflow/action/with_sub_plans.rb +20 -19
  40. data/lib/dynflow/action.rb +37 -37
  41. data/lib/dynflow/active_job/queue_adapter.rb +2 -1
  42. data/lib/dynflow/actor.rb +2 -2
  43. data/lib/dynflow/actors/execution_plan_cleaner.rb +1 -0
  44. data/lib/dynflow/actors.rb +1 -0
  45. data/lib/dynflow/clock.rb +3 -4
  46. data/lib/dynflow/config.rb +6 -5
  47. data/lib/dynflow/connectors/abstract.rb +11 -10
  48. data/lib/dynflow/connectors/database.rb +2 -2
  49. data/lib/dynflow/connectors/direct.rb +2 -3
  50. data/lib/dynflow/connectors.rb +1 -0
  51. data/lib/dynflow/coordinator.rb +2 -6
  52. data/lib/dynflow/coordinator_adapters/abstract.rb +1 -0
  53. data/lib/dynflow/coordinator_adapters/sequel.rb +1 -0
  54. data/lib/dynflow/coordinator_adapters.rb +1 -2
  55. data/lib/dynflow/dead_letter_silencer.rb +1 -0
  56. data/lib/dynflow/debug/telemetry/persistence.rb +3 -2
  57. data/lib/dynflow/delayed_executors/abstract.rb +1 -2
  58. data/lib/dynflow/delayed_executors/abstract_core.rb +1 -1
  59. data/lib/dynflow/delayed_executors/polling.rb +1 -2
  60. data/lib/dynflow/delayed_executors.rb +1 -2
  61. data/lib/dynflow/delayed_plan.rb +6 -6
  62. data/lib/dynflow/director/execution_plan_manager.rb +1 -1
  63. data/lib/dynflow/director/flow_manager.rb +1 -0
  64. data/lib/dynflow/director/queue_hash.rb +2 -1
  65. data/lib/dynflow/director/running_steps_manager.rb +3 -2
  66. data/lib/dynflow/director/sequence_cursor.rb +1 -2
  67. data/lib/dynflow/director/sequential_manager.rb +1 -0
  68. data/lib/dynflow/director.rb +12 -11
  69. data/lib/dynflow/dispatcher/abstract.rb +1 -0
  70. data/lib/dynflow/dispatcher/client_dispatcher.rb +33 -33
  71. data/lib/dynflow/dispatcher/executor_dispatcher.rb +7 -6
  72. data/lib/dynflow/dispatcher.rb +8 -7
  73. data/lib/dynflow/errors.rb +1 -0
  74. data/lib/dynflow/execution_history.rb +2 -1
  75. data/lib/dynflow/execution_plan/dependency_graph.rb +1 -2
  76. data/lib/dynflow/execution_plan/hooks.rb +1 -1
  77. data/lib/dynflow/execution_plan/output_reference.rb +4 -4
  78. data/lib/dynflow/execution_plan/steps/abstract.rb +21 -20
  79. data/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +1 -1
  80. data/lib/dynflow/execution_plan/steps/error.rb +10 -9
  81. data/lib/dynflow/execution_plan/steps/finalize_step.rb +1 -2
  82. data/lib/dynflow/execution_plan/steps/plan_step.rb +12 -11
  83. data/lib/dynflow/execution_plan/steps/run_step.rb +1 -1
  84. data/lib/dynflow/execution_plan/steps.rb +1 -2
  85. data/lib/dynflow/execution_plan.rb +46 -46
  86. data/lib/dynflow/executors/abstract/core.rb +4 -3
  87. data/lib/dynflow/executors/parallel/core.rb +3 -2
  88. data/lib/dynflow/executors/parallel/pool.rb +1 -4
  89. data/lib/dynflow/executors/parallel/worker.rb +1 -0
  90. data/lib/dynflow/executors/parallel.rb +3 -2
  91. data/lib/dynflow/executors/sidekiq/core.rb +3 -1
  92. data/lib/dynflow/executors/sidekiq/internal_job_base.rb +1 -0
  93. data/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb +1 -0
  94. data/lib/dynflow/executors/sidekiq/redis_locking.rb +1 -0
  95. data/lib/dynflow/executors/sidekiq/serialization.rb +1 -0
  96. data/lib/dynflow/executors/sidekiq/worker_jobs.rb +1 -0
  97. data/lib/dynflow/executors.rb +1 -1
  98. data/lib/dynflow/extensions/msgpack.rb +5 -4
  99. data/lib/dynflow/extensions.rb +1 -0
  100. data/lib/dynflow/flows/abstract.rb +1 -1
  101. data/lib/dynflow/flows/abstract_composed.rb +1 -2
  102. data/lib/dynflow/flows/atom.rb +1 -2
  103. data/lib/dynflow/flows/concurrence.rb +1 -1
  104. data/lib/dynflow/flows/registry.rb +1 -0
  105. data/lib/dynflow/flows/sequence.rb +1 -1
  106. data/lib/dynflow/flows.rb +1 -2
  107. data/lib/dynflow/logger_adapters/abstract.rb +1 -1
  108. data/lib/dynflow/logger_adapters/delegator.rb +1 -1
  109. data/lib/dynflow/logger_adapters/formatters/abstract.rb +1 -0
  110. data/lib/dynflow/logger_adapters/formatters/exception.rb +1 -0
  111. data/lib/dynflow/logger_adapters/formatters.rb +1 -0
  112. data/lib/dynflow/logger_adapters/simple.rb +6 -5
  113. data/lib/dynflow/logger_adapters.rb +1 -0
  114. data/lib/dynflow/middleware/common/singleton.rb +1 -0
  115. data/lib/dynflow/middleware/common/transaction.rb +1 -0
  116. data/lib/dynflow/middleware/register.rb +1 -0
  117. data/lib/dynflow/middleware/resolver.rb +2 -3
  118. data/lib/dynflow/middleware/stack.rb +1 -0
  119. data/lib/dynflow/middleware/world.rb +1 -2
  120. data/lib/dynflow/middleware.rb +1 -0
  121. data/lib/dynflow/persistence.rb +4 -5
  122. data/lib/dynflow/persistence_adapters/abstract.rb +1 -1
  123. data/lib/dynflow/persistence_adapters/sequel.rb +14 -14
  124. data/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +2 -1
  125. data/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb +1 -0
  126. data/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb +1 -0
  127. data/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +1 -1
  128. data/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb +1 -0
  129. data/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb +1 -0
  130. data/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb +1 -0
  131. data/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb +1 -0
  132. data/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +1 -1
  133. data/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb +1 -0
  134. data/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb +1 -0
  135. data/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb +1 -0
  136. data/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb +1 -0
  137. data/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb +1 -0
  138. data/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb +1 -0
  139. data/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb +1 -0
  140. data/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb +1 -0
  141. data/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +37 -30
  142. data/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +1 -0
  143. data/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb +1 -0
  144. data/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb +4 -3
  145. data/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb +1 -0
  146. data/lib/dynflow/persistence_adapters.rb +1 -0
  147. data/lib/dynflow/rails/configuration.rb +5 -4
  148. data/lib/dynflow/rails/daemon.rb +1 -1
  149. data/lib/dynflow/rails.rb +3 -2
  150. data/lib/dynflow/round_robin.rb +2 -2
  151. data/lib/dynflow/semaphores/abstract.rb +1 -1
  152. data/lib/dynflow/semaphores/aggregating.rb +1 -2
  153. data/lib/dynflow/semaphores/dummy.rb +1 -1
  154. data/lib/dynflow/semaphores/stateful.rb +1 -1
  155. data/lib/dynflow/semaphores.rb +1 -0
  156. data/lib/dynflow/serializable.rb +1 -0
  157. data/lib/dynflow/serializer.rb +2 -2
  158. data/lib/dynflow/serializers/abstract.rb +1 -2
  159. data/lib/dynflow/serializers/noop.rb +1 -2
  160. data/lib/dynflow/serializers.rb +1 -2
  161. data/lib/dynflow/stateful.rb +1 -0
  162. data/lib/dynflow/telemetry.rb +11 -10
  163. data/lib/dynflow/telemetry_adapters/abstract.rb +1 -0
  164. data/lib/dynflow/telemetry_adapters/dummy.rb +1 -0
  165. data/lib/dynflow/telemetry_adapters/statsd.rb +2 -1
  166. data/lib/dynflow/testing/assertions.rb +7 -7
  167. data/lib/dynflow/testing/dummy_coordinator.rb +1 -0
  168. data/lib/dynflow/testing/dummy_execution_plan.rb +1 -0
  169. data/lib/dynflow/testing/dummy_executor.rb +1 -0
  170. data/lib/dynflow/testing/dummy_planned_action.rb +3 -1
  171. data/lib/dynflow/testing/dummy_step.rb +1 -0
  172. data/lib/dynflow/testing/dummy_world.rb +1 -0
  173. data/lib/dynflow/testing/factories.rb +42 -37
  174. data/lib/dynflow/testing/in_thread_executor.rb +1 -0
  175. data/lib/dynflow/testing/in_thread_world.rb +1 -0
  176. data/lib/dynflow/testing/managed_clock.rb +1 -1
  177. data/lib/dynflow/testing/mimic.rb +4 -4
  178. data/lib/dynflow/testing.rb +1 -0
  179. data/lib/dynflow/throttle_limiter.rb +1 -1
  180. data/lib/dynflow/transaction_adapters/abstract.rb +1 -0
  181. data/lib/dynflow/transaction_adapters/active_record.rb +1 -0
  182. data/lib/dynflow/transaction_adapters/none.rb +1 -0
  183. data/lib/dynflow/transaction_adapters.rb +1 -2
  184. data/lib/dynflow/utils/indifferent_hash.rb +7 -1
  185. data/lib/dynflow/utils/priority_queue.rb +1 -0
  186. data/lib/dynflow/utils.rb +1 -1
  187. data/lib/dynflow/version.rb +2 -1
  188. data/lib/dynflow/watchers/memory_consumption_watcher.rb +1 -1
  189. data/lib/dynflow/web/console.rb +1 -3
  190. data/lib/dynflow/web/console_helpers.rb +5 -4
  191. data/lib/dynflow/web/filtering_helpers.rb +1 -0
  192. data/lib/dynflow/web/world_helpers.rb +1 -0
  193. data/lib/dynflow/web.rb +3 -3
  194. data/lib/dynflow/web_console.rb +1 -0
  195. data/lib/dynflow/world/invalidation.rb +1 -0
  196. data/lib/dynflow/world.rb +19 -19
  197. data/lib/dynflow.rb +3 -6
  198. data/test/abnormal_states_recovery_test.rb +4 -8
  199. data/test/action_test.rb +10 -18
  200. data/test/activejob_adapter_test.rb +2 -2
  201. data/test/batch_sub_tasks_test.rb +1 -1
  202. data/test/clock_test.rb +2 -3
  203. data/test/concurrency_control_test.rb +6 -7
  204. data/test/coordinator_test.rb +1 -0
  205. data/test/daemon_test.rb +3 -2
  206. data/test/dead_letter_silencer_test.rb +2 -1
  207. data/test/dispatcher_test.rb +4 -5
  208. data/test/execution_plan_cleaner_test.rb +1 -0
  209. data/test/execution_plan_hooks_test.rb +1 -0
  210. data/test/execution_plan_test.rb +10 -32
  211. data/test/executor_test.rb +20 -37
  212. data/test/extensions_test.rb +1 -0
  213. data/test/flows_test.rb +2 -2
  214. data/test/future_execution_test.rb +2 -3
  215. data/test/memory_cosumption_watcher_test.rb +1 -0
  216. data/test/middleware_test.rb +4 -6
  217. data/test/persistence_test.rb +26 -26
  218. data/test/redis_locking_test.rb +1 -0
  219. data/test/rescue_test.rb +3 -11
  220. data/test/round_robin_test.rb +1 -0
  221. data/test/semaphores_test.rb +5 -7
  222. data/test/support/code_workflow_example.rb +11 -28
  223. data/test/support/dummy_example.rb +20 -19
  224. data/test/support/middleware_example.rb +2 -8
  225. data/test/support/rescue_example.rb +1 -14
  226. data/test/support/test_execution_log.rb +1 -2
  227. data/test/test_helper.rb +3 -7
  228. data/test/testing_test.rb +6 -8
  229. data/test/utils_test.rb +1 -0
  230. data/test/v2_sub_plans_test.rb +1 -0
  231. data/test/web_console_test.rb +4 -4
  232. data/test/world_test.rb +4 -3
  233. metadata +43 -43
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  class Middleware::World
4
-
5
5
  include Algebrick::TypeCheck
6
6
 
7
7
  def initialize
@@ -54,6 +54,5 @@ module Dynflow
54
54
  end
55
55
  return @middleware_classes_cache[action_class]
56
56
  end
57
-
58
57
  end
59
58
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  class Middleware
4
5
  require 'dynflow/middleware/register'
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'dynflow/persistence_adapters'
3
4
 
4
5
  module Dynflow
5
-
6
6
  class Persistence
7
-
8
7
  include Algebrick::TypeCheck
9
8
 
10
9
  attr_reader :adapter
@@ -18,9 +17,9 @@ module Dynflow
18
17
  end
19
18
 
20
19
  def load_action(step)
21
- attributes = adapter.
22
- load_action(step.execution_plan_id, step.action_id).
23
- update(step: step, phase: step.phase)
20
+ attributes = adapter
21
+ .load_action(step.execution_plan_id, step.action_id)
22
+ .update(step: step, phase: step.phase)
24
23
  return Action.from_hash(attributes, step.world)
25
24
  end
26
25
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module PersistenceAdapters
4
5
  class Abstract
5
-
6
6
  # The logger is set by the world when used inside it
7
7
  attr_accessor :logger
8
8
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'sequel'
3
4
  require 'msgpack'
4
5
  require 'fileutils'
@@ -7,7 +8,6 @@ require 'csv'
7
8
  # rubocop:disable Metrics/ClassLength
8
9
  module Dynflow
9
10
  module PersistenceAdapters
10
-
11
11
  Sequel.extension :migration
12
12
  Sequel.database_timezone = :utc
13
13
 
@@ -67,10 +67,10 @@ module Dynflow
67
67
  table_name = :execution_plan
68
68
  options[:order_by] ||= :started_at
69
69
  data_set = filter(table_name,
70
- order(table_name,
71
- paginate(table(table_name), options),
72
- options),
73
- options[:filters])
70
+ order(table_name,
71
+ paginate(table(table_name), options),
72
+ options),
73
+ options[:filters])
74
74
  data_set.all.map { |record| execution_plan_column_map(load_data(record, table_name)) }
75
75
  end
76
76
 
@@ -80,7 +80,7 @@ module Dynflow
80
80
 
81
81
  def find_execution_plan_statuses(options)
82
82
  plans = filter(:execution_plan, table(:execution_plan), options[:filters])
83
- .select(:uuid, :state, :result)
83
+ .select(:uuid, :state, :result)
84
84
 
85
85
  plans.each_with_object({}) do |current, acc|
86
86
  uuid = current.delete(:uuid)
@@ -99,7 +99,7 @@ module Dynflow
99
99
  backup_to_csv(:step, steps, backup_dir, 'steps.csv') if backup_dir
100
100
  steps.delete
101
101
 
102
- output_chunks = table(:output_chunk).where(execution_plan_uuid: uuids).delete
102
+ table(:output_chunk).where(execution_plan_uuid: uuids).delete
103
103
 
104
104
  actions = table(:action).where(execution_plan_uuid: uuids)
105
105
  backup_to_csv(:action, actions, backup_dir, 'actions.csv') if backup_dir
@@ -169,7 +169,7 @@ module Dynflow
169
169
 
170
170
  def save_step(execution_plan_id, step_id, value, update_conditions = {})
171
171
  save :step, { execution_plan_uuid: execution_plan_id, id: step_id }, value,
172
- with_data: false, update_conditions: update_conditions
172
+ with_data: false, update_conditions: update_conditions
173
173
  end
174
174
 
175
175
  def load_action(execution_plan_id, action_id)
@@ -254,7 +254,7 @@ module Dynflow
254
254
 
255
255
  def update_coordinator_record(class_name, record_id, value)
256
256
  coordinator_feature!
257
- save :coordinator_record, {class: class_name, :id => record_id}, value
257
+ save :coordinator_record, { class: class_name, :id => record_id }, value
258
258
  end
259
259
 
260
260
  def delete_coordinator_record(class_name, record_id)
@@ -365,7 +365,7 @@ module Dynflow
365
365
 
366
366
  def load_record(what, condition)
367
367
  table = table(what)
368
- if (record = with_retry { table.first(Utils.symbolize_keys(condition)) } )
368
+ if (record = with_retry { table.first(Utils.symbolize_keys(condition)) })
369
369
  load_data(record, what)
370
370
  else
371
371
  raise KeyError, "searching: #{what} by: #{condition.inspect}"
@@ -491,13 +491,13 @@ module Dynflow
491
491
  end
492
492
 
493
493
  if filters.key?('caller_execution_plan_id')
494
- data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid).
495
- select_all(TABLES[:execution_plan]).distinct
494
+ data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid)
495
+ .select_all(TABLES[:execution_plan]).distinct
496
496
  end
497
497
  if filters.key?('delayed')
498
498
  filters.delete('delayed')
499
- data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid).
500
- select_all(TABLES[:execution_plan]).distinct
499
+ data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid)
500
+ .select_all(TABLES[:execution_plan]).distinct
501
501
  end
502
502
  end
503
503
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  up do
4
5
  create_table(:dynflow_execution_plans) do
@@ -33,7 +34,7 @@ Sequel.migration do
33
34
  index [:execution_plan_uuid, :id], :unique => true
34
35
  column :action_id, Integer
35
36
  foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions,
36
- name: :dynflow_steps_execution_plan_uuid_fkey1
37
+ name: :dynflow_steps_execution_plan_uuid_fkey1
37
38
  index [:execution_plan_uuid, :action_id]
38
39
 
39
40
  column :data, String, text: true
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_steps) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_actions) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  create_table(:dynflow_coordinator_records) do
@@ -12,4 +13,3 @@ Sequel.migration do
12
13
  end
13
14
  end
14
15
  end
15
-
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  create_table(:dynflow_envelopes) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  up do
4
5
  alter_table(:dynflow_steps) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  create_table(:dynflow_scheduled_plans) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  rename_table(:dynflow_scheduled_plans, :dynflow_delayed_plans)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  affected_tables = [:dynflow_actions, :dynflow_coordinator_records, :dynflow_delayed_plans,
4
5
  :dynflow_envelopes, :dynflow_execution_plans]
@@ -22,4 +23,3 @@ Sequel.migration do
22
23
  end
23
24
  end
24
25
  end
25
-
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_execution_plans) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  # Placeholder for 011_add_uuid_column.rb - it was readded in
4
5
  # 018_add_uuid_column.rb with fixed check for postgresql
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_delayed_plans) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_actions) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_steps) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_execution_plans) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_steps) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  change do
4
5
  alter_table(:dynflow_delayed_plans) do
@@ -1,45 +1,50 @@
1
1
  # frozen_string_literal: true
2
- def to_uuid(table_name, column_name)
3
- set_column_type(table_name, column_name, :uuid, :using => "#{column_name}::uuid")
4
- end
5
-
6
- def from_uuid(table_name, column_name)
7
- set_column_type table_name, column_name, String, primary_key: true, size: 36, fixed: true
8
- end
9
2
 
10
- def with_foreign_key_recreation(&block)
11
- # Drop the foreign key constraints so we can change the column type
12
- alter_table :dynflow_actions do
13
- drop_foreign_key [:execution_plan_uuid]
14
- end
15
- alter_table :dynflow_steps do
16
- drop_foreign_key [:execution_plan_uuid]
17
- drop_foreign_key [:execution_plan_uuid, :action_id], :name => :dynflow_steps_execution_plan_uuid_fkey1
3
+ helper = Module.new do
4
+ def to_uuid(table_name, column_name)
5
+ set_column_type(table_name, column_name, :uuid, :using => "#{column_name}::uuid")
18
6
  end
19
- alter_table :dynflow_delayed_plans do
20
- drop_foreign_key [:execution_plan_uuid]
7
+
8
+ def from_uuid(table_name, column_name)
9
+ set_column_type table_name, column_name, String, primary_key: true, size: 36, fixed: true
21
10
  end
22
11
 
23
- block.call
12
+ def with_foreign_key_recreation(&block)
13
+ # Drop the foreign key constraints so we can change the column type
14
+ alter_table :dynflow_actions do
15
+ drop_foreign_key [:execution_plan_uuid]
16
+ end
17
+ alter_table :dynflow_steps do
18
+ drop_foreign_key [:execution_plan_uuid]
19
+ drop_foreign_key [:execution_plan_uuid, :action_id], :name => :dynflow_steps_execution_plan_uuid_fkey1
20
+ end
21
+ alter_table :dynflow_delayed_plans do
22
+ drop_foreign_key [:execution_plan_uuid]
23
+ end
24
+
25
+ block.call
24
26
 
25
- # Recreat the foreign key constraints as they were before
26
- alter_table :dynflow_actions do
27
- add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
28
- end
29
- alter_table :dynflow_steps do
30
- add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
31
- add_foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions,
32
- :name => :dynflow_steps_execution_plan_uuid_fkey1
33
- end
34
- alter_table :dynflow_delayed_plans do
35
- add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans,
36
- :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey
27
+ # Recreat the foreign key constraints as they were before
28
+ alter_table :dynflow_actions do
29
+ add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
30
+ end
31
+ alter_table :dynflow_steps do
32
+ add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans
33
+ add_foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions,
34
+ :name => :dynflow_steps_execution_plan_uuid_fkey1
35
+ end
36
+ alter_table :dynflow_delayed_plans do
37
+ add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans,
38
+ :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey
39
+ end
37
40
  end
38
41
  end
39
42
 
40
43
  Sequel.migration do
41
44
  up do
42
45
  if database_type.to_s.include?('postgres')
46
+ Sequel::Postgres::Database.include helper
47
+
43
48
  with_foreign_key_recreation do
44
49
  to_uuid :dynflow_execution_plans, :uuid
45
50
  to_uuid :dynflow_actions, :execution_plan_uuid
@@ -51,6 +56,8 @@ Sequel.migration do
51
56
 
52
57
  down do
53
58
  if database_type.to_s.include?('postgres')
59
+ Sequel::Postgres::Database.include helper
60
+
54
61
  with_foreign_key_recreation do
55
62
  from_uuid :dynflow_execution_plans, :uuid
56
63
  from_uuid :dynflow_actions, :execution_plan_uuid
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  up do
4
5
  alter_table(:dynflow_execution_plans) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  up do
4
5
  alter_table(:dynflow_actions) do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Sequel.migration do
3
4
  up do
4
5
  type = database_type
@@ -6,16 +7,16 @@ Sequel.migration do
6
7
  primary_key :id
7
8
 
8
9
  column_properties = if type.to_s.include?('postgres')
9
- {type: :uuid}
10
+ { type: :uuid }
10
11
  else
11
- {type: String, size: 36, fixed: true, null: false}
12
+ { type: String, size: 36, fixed: true, null: false }
12
13
  end
13
14
  foreign_key :execution_plan_uuid, :dynflow_execution_plans, **column_properties
14
15
  index :execution_plan_uuid
15
16
 
16
17
  column :action_id, Integer, null: false
17
18
  foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions,
18
- name: :dynflow_output_chunks_execution_plan_uuid_fkey1
19
+ name: :dynflow_output_chunks_execution_plan_uuid_fkey1
19
20
  index [:execution_plan_uuid, :action_id]
20
21
 
21
22
  column :chunk, String, text: true
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  tables = [:dynflow_actions, :dynflow_delayed_plans, :dynflow_steps, :dynflow_output_chunks]
3
4
  Sequel.migration do
4
5
  up do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module PersistenceAdapters
4
5
  require 'dynflow/persistence_adapters/abstract'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rails'
3
4
  require 'active_record'
4
5
 
@@ -100,7 +101,7 @@ module Dynflow
100
101
  end
101
102
 
102
103
  def sidekiq_worker?
103
- defined?(::Sidekiq) && ::Sidekiq.options[:queues].any?
104
+ defined?(::Sidekiq) && ::Sidekiq.configure_server { |c| c[:queues].any? }
104
105
  end
105
106
 
106
107
  def calculate_db_pool_size(world)
@@ -108,7 +109,7 @@ module Dynflow
108
109
 
109
110
  base_value = 5
110
111
  if defined?(::Sidekiq)
111
- Sidekiq.options[:concurrency] + base_value
112
+ Sidekiq.configure_server { |c| c[:concurrency] } + base_value
112
113
  else
113
114
  world.config.queues.values.inject(base_value) do |pool_size, pool_options|
114
115
  pool_size += pool_options[:pool_size]
@@ -152,7 +153,7 @@ module Dynflow
152
153
  # we can't do any operation until the Rails.application.dynflow.world is set
153
154
  config.auto_execute = false
154
155
  config.auto_validity_check = false
155
- if sidekiq_worker? && !Sidekiq.options[:queues].include?("dynflow_orchestrator")
156
+ if sidekiq_worker? && !Sidekiq.configure_server { |c| c[:queues].include?("dynflow_orchestrator") }
156
157
  config.delayed_executor = nil
157
158
  end
158
159
  end
@@ -192,7 +193,7 @@ module Dynflow
192
193
  if remote?
193
194
  false
194
195
  else
195
- if defined?(::Sidekiq) && Sidekiq.options[:dynflow_executor]
196
+ if defined?(::Sidekiq) && Sidekiq.configure_server { |c| c[:dynflow_executor] }
196
197
  ::Dynflow::Executors::Sidekiq::Core
197
198
  else
198
199
  ::Dynflow::Executors::Parallel::Core
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'fileutils'
3
4
  require 'get_process_mem'
4
5
  require 'dynflow/watchers/memory_consumption_watcher'
@@ -175,7 +176,6 @@ module Dynflow
175
176
  else raise "Unknown unit: #{unit.inspect}!"
176
177
  end
177
178
  end
178
-
179
179
  end
180
180
  end
181
181
  end
data/lib/dynflow/rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # frozen_string_literal: true
3
+
3
4
  module Dynflow
4
5
  # Class for configuring and preparing the Dynflow runtime environment.
5
6
  class Rails
@@ -32,8 +33,8 @@ module Dynflow
32
33
  return @world if @world
33
34
 
34
35
  if config.lazy_initialization && defined?(::PhusionPassenger)
35
- config.dynflow_logger.
36
- warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results')
36
+ config.dynflow_logger
37
+ .warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results')
37
38
  end
38
39
  init_world.tap do |world|
39
40
  @world = world
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  # A simple round-robin scheduling implementation used at various
4
5
  # places in Dynflow
@@ -19,7 +20,7 @@ module Dynflow
19
20
  end
20
21
 
21
22
  def next
22
- @cursor = 0 if @cursor > @data.size-1
23
+ @cursor = 0 if @cursor > @data.size - 1
23
24
  @data[@cursor]
24
25
  ensure
25
26
  @cursor += 1
@@ -35,4 +36,3 @@ module Dynflow
35
36
  attr_writer :data
36
37
  end
37
38
  end
38
-
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Semaphores
4
5
  class Abstract
5
-
6
6
  # Tries to get ticket from the semaphore
7
7
  # Returns true if thing got a ticket
8
8
  # Rturns false otherwise and puts the thing into the semaphore's queue
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Semaphores
4
5
  class Aggregating < Abstract
5
-
6
6
  attr_reader :children, :waiting
7
7
 
8
8
  def initialize(children)
@@ -58,7 +58,6 @@ module Dynflow
58
58
  @children[key].release n
59
59
  end
60
60
  end
61
-
62
61
  end
63
62
  end
64
63
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Semaphores
4
5
  class Dummy < Abstract
5
-
6
6
  def wait(thing)
7
7
  true
8
8
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Semaphores
4
5
  class Stateful < Abstract
5
-
6
6
  attr_reader :free, :tickets, :waiting, :meta
7
7
 
8
8
  def initialize(tickets, free = tickets, meta = {})
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Semaphores
4
5
  require 'dynflow/semaphores/abstract'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'date'
3
4
  module Dynflow
4
5
  class Serializable
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'algebrick/serializer'
3
4
 
4
5
  module Dynflow
@@ -7,7 +8,6 @@ module Dynflow
7
8
  end
8
9
 
9
10
  class Serializer < Algebrick::Serializer
10
-
11
11
  ARBITRARY_TYPE_KEY = :class
12
12
  MARSHAL_KEY = :marshaled
13
13
 
@@ -38,7 +38,7 @@ module Dynflow
38
38
  end
39
39
 
40
40
  if (type_name = other[ARBITRARY_TYPE_KEY] || other[ARBITRARY_TYPE_KEY.to_s])
41
- if type_name == 'Time' && ( time_str = other['value'] )
41
+ if type_name == 'Time' && (time_str = other['value'])
42
42
  return Serializable.send(:string_to_time, time_str)
43
43
  end
44
44
  type = Utils.constantize(type_name) rescue nil
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Serializers
4
5
  # @abstract
@@ -6,7 +7,6 @@ module Dynflow
6
7
  # Used by {DelayedPlan} to store arguments which should be passed into
7
8
  # the {Dynflow::Action}'s #plan method when the plan is executed.
8
9
  class Abstract
9
-
10
10
  attr_reader :args, :serialized_args
11
11
 
12
12
  # @param args [Array] arguments to be serialized
@@ -65,7 +65,6 @@ module Dynflow
65
65
  def deserialize(arg)
66
66
  raise NotImplementedError
67
67
  end
68
-
69
68
  end
70
69
  end
71
70
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Dynflow
3
4
  module Serializers
4
5
  class Noop < Abstract
5
-
6
6
  def serialize(arg)
7
7
  arg
8
8
  end
@@ -10,7 +10,6 @@ module Dynflow
10
10
  def deserialize(arg)
11
11
  arg
12
12
  end
13
-
14
13
  end
15
14
  end
16
15
  end