dynflow 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +3 -4
- data/Dockerfile +9 -0
- data/Gemfile +6 -0
- data/Rakefile +1 -0
- data/doc/pages/Gemfile +1 -0
- data/doc/pages/Rakefile +1 -0
- data/doc/pages/plugins/alert_block.rb +1 -0
- data/doc/pages/plugins/div_tag.rb +1 -0
- data/doc/pages/plugins/graphviz.rb +1 -0
- data/doc/pages/plugins/plantuml.rb +1 -0
- data/doc/pages/plugins/play.rb +1 -0
- data/doc/pages/plugins/tags.rb +1 -0
- data/doc/pages/plugins/toc.rb +1 -0
- data/docker-compose.yml +41 -0
- data/dynflow.gemspec +1 -0
- data/examples/clock_benchmark.rb +1 -0
- data/examples/example_helper.rb +19 -2
- data/examples/future_execution.rb +2 -1
- data/examples/memory_limit_watcher.rb +1 -0
- data/examples/orchestrate.rb +4 -5
- data/examples/orchestrate_evented.rb +3 -2
- data/examples/remote_executor.rb +68 -0
- data/examples/singletons.rb +4 -3
- data/examples/sub_plan_concurrency_control.rb +2 -1
- data/examples/sub_plans.rb +3 -2
- data/examples/termination.rb +1 -0
- data/lib/dynflow.rb +20 -0
- data/lib/dynflow/action.rb +28 -3
- data/lib/dynflow/action/cancellable.rb +1 -0
- data/lib/dynflow/action/format.rb +1 -0
- data/lib/dynflow/action/missing.rb +1 -0
- data/lib/dynflow/action/polling.rb +3 -1
- data/lib/dynflow/action/progress.rb +1 -0
- data/lib/dynflow/action/rescue.rb +1 -0
- data/lib/dynflow/action/singleton.rb +1 -0
- data/lib/dynflow/action/suspended.rb +9 -2
- data/lib/dynflow/action/timeouts.rb +2 -1
- data/lib/dynflow/action/with_bulk_sub_plans.rb +2 -1
- data/lib/dynflow/action/with_polling_sub_plans.rb +7 -5
- data/lib/dynflow/action/with_sub_plans.rb +1 -0
- data/lib/dynflow/active_job/queue_adapter.rb +1 -0
- data/lib/dynflow/actor.rb +13 -5
- data/lib/dynflow/actors.rb +1 -0
- data/lib/dynflow/actors/execution_plan_cleaner.rb +1 -0
- data/lib/dynflow/clock.rb +27 -47
- data/lib/dynflow/config.rb +11 -2
- data/lib/dynflow/connectors.rb +1 -0
- data/lib/dynflow/connectors/abstract.rb +1 -0
- data/lib/dynflow/connectors/database.rb +1 -0
- data/lib/dynflow/connectors/direct.rb +1 -0
- data/lib/dynflow/coordinator.rb +1 -0
- data/lib/dynflow/coordinator_adapters.rb +1 -0
- data/lib/dynflow/coordinator_adapters/abstract.rb +1 -0
- data/lib/dynflow/coordinator_adapters/sequel.rb +1 -0
- data/lib/dynflow/dead_letter_silencer.rb +2 -0
- data/lib/dynflow/debug/telemetry/persistence.rb +1 -0
- data/lib/dynflow/delayed_executors.rb +1 -0
- data/lib/dynflow/delayed_executors/abstract.rb +1 -0
- data/lib/dynflow/delayed_executors/abstract_core.rb +1 -0
- data/lib/dynflow/delayed_executors/polling.rb +1 -0
- data/lib/dynflow/delayed_plan.rb +1 -0
- data/lib/dynflow/director.rb +80 -15
- data/lib/dynflow/director/execution_plan_manager.rb +17 -3
- data/lib/dynflow/director/flow_manager.rb +1 -0
- data/lib/dynflow/director/{work_queue.rb → queue_hash.rb} +9 -8
- data/lib/dynflow/director/running_steps_manager.rb +55 -18
- data/lib/dynflow/director/sequence_cursor.rb +1 -0
- data/lib/dynflow/director/sequential_manager.rb +12 -2
- data/lib/dynflow/dispatcher.rb +4 -2
- data/lib/dynflow/dispatcher/abstract.rb +1 -0
- data/lib/dynflow/dispatcher/client_dispatcher.rb +6 -4
- data/lib/dynflow/dispatcher/executor_dispatcher.rb +13 -1
- data/lib/dynflow/errors.rb +1 -0
- data/lib/dynflow/execution_history.rb +1 -0
- data/lib/dynflow/execution_plan.rb +3 -2
- data/lib/dynflow/execution_plan/dependency_graph.rb +1 -0
- data/lib/dynflow/execution_plan/hooks.rb +1 -0
- data/lib/dynflow/execution_plan/output_reference.rb +2 -1
- data/lib/dynflow/execution_plan/steps.rb +1 -0
- data/lib/dynflow/execution_plan/steps/abstract.rb +10 -5
- data/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +2 -0
- data/lib/dynflow/execution_plan/steps/error.rb +1 -0
- data/lib/dynflow/execution_plan/steps/finalize_step.rb +1 -0
- data/lib/dynflow/execution_plan/steps/plan_step.rb +1 -0
- data/lib/dynflow/execution_plan/steps/run_step.rb +1 -0
- data/lib/dynflow/executors.rb +1 -1
- data/lib/dynflow/executors/abstract/core.rb +132 -0
- data/lib/dynflow/executors/parallel.rb +24 -11
- data/lib/dynflow/executors/parallel/core.rb +10 -91
- data/lib/dynflow/executors/parallel/pool.rb +4 -2
- data/lib/dynflow/executors/parallel/worker.rb +2 -1
- data/lib/dynflow/executors/sidekiq/core.rb +121 -0
- data/lib/dynflow/executors/sidekiq/internal_job_base.rb +24 -0
- data/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb +60 -0
- data/lib/dynflow/executors/sidekiq/redis_locking.rb +69 -0
- data/lib/dynflow/executors/sidekiq/serialization.rb +33 -0
- data/lib/dynflow/executors/sidekiq/worker_jobs.rb +42 -0
- data/lib/dynflow/flows.rb +1 -0
- data/lib/dynflow/flows/abstract.rb +1 -0
- data/lib/dynflow/flows/abstract_composed.rb +1 -0
- data/lib/dynflow/flows/atom.rb +1 -0
- data/lib/dynflow/flows/concurrence.rb +1 -0
- data/lib/dynflow/flows/sequence.rb +1 -0
- data/lib/dynflow/logger_adapters.rb +1 -0
- data/lib/dynflow/logger_adapters/abstract.rb +1 -0
- data/lib/dynflow/logger_adapters/delegator.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters/abstract.rb +1 -0
- data/lib/dynflow/logger_adapters/formatters/exception.rb +1 -0
- data/lib/dynflow/logger_adapters/simple.rb +1 -0
- data/lib/dynflow/middleware.rb +1 -0
- data/lib/dynflow/middleware/common/singleton.rb +1 -0
- data/lib/dynflow/middleware/common/transaction.rb +1 -0
- data/lib/dynflow/middleware/register.rb +1 -0
- data/lib/dynflow/middleware/resolver.rb +1 -0
- data/lib/dynflow/middleware/stack.rb +1 -0
- data/lib/dynflow/middleware/world.rb +1 -0
- data/lib/dynflow/persistence.rb +3 -2
- data/lib/dynflow/persistence_adapters.rb +1 -0
- data/lib/dynflow/persistence_adapters/abstract.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel.rb +10 -7
- data/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +1 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +48 -0
- data/lib/dynflow/rails.rb +1 -0
- data/lib/dynflow/rails/configuration.rb +6 -3
- data/lib/dynflow/rails/daemon.rb +1 -0
- data/lib/dynflow/round_robin.rb +1 -0
- data/lib/dynflow/semaphores.rb +1 -0
- data/lib/dynflow/semaphores/abstract.rb +1 -0
- data/lib/dynflow/semaphores/aggregating.rb +1 -0
- data/lib/dynflow/semaphores/dummy.rb +1 -0
- data/lib/dynflow/semaphores/stateful.rb +1 -0
- data/lib/dynflow/serializable.rb +13 -4
- data/lib/dynflow/serializer.rb +24 -0
- data/lib/dynflow/serializers.rb +1 -0
- data/lib/dynflow/serializers/abstract.rb +1 -0
- data/lib/dynflow/serializers/noop.rb +1 -0
- data/lib/dynflow/stateful.rb +1 -0
- data/lib/dynflow/telemetry.rb +1 -0
- data/lib/dynflow/telemetry_adapters/abstract.rb +1 -0
- data/lib/dynflow/telemetry_adapters/dummy.rb +1 -0
- data/lib/dynflow/telemetry_adapters/statsd.rb +1 -0
- data/lib/dynflow/testing.rb +1 -0
- data/lib/dynflow/testing/assertions.rb +6 -5
- data/lib/dynflow/testing/dummy_execution_plan.rb +1 -0
- data/lib/dynflow/testing/dummy_executor.rb +19 -2
- data/lib/dynflow/testing/dummy_planned_action.rb +1 -0
- data/lib/dynflow/testing/dummy_step.rb +3 -1
- data/lib/dynflow/testing/dummy_world.rb +9 -0
- data/lib/dynflow/testing/factories.rb +6 -1
- data/lib/dynflow/testing/in_thread_executor.rb +22 -3
- data/lib/dynflow/testing/in_thread_world.rb +9 -0
- data/lib/dynflow/testing/managed_clock.rb +1 -0
- data/lib/dynflow/testing/mimic.rb +1 -0
- data/lib/dynflow/throttle_limiter.rb +1 -0
- data/lib/dynflow/transaction_adapters.rb +1 -0
- data/lib/dynflow/transaction_adapters/abstract.rb +1 -0
- data/lib/dynflow/transaction_adapters/active_record.rb +1 -0
- data/lib/dynflow/transaction_adapters/none.rb +1 -0
- data/lib/dynflow/utils.rb +1 -0
- data/lib/dynflow/utils/indifferent_hash.rb +1 -0
- data/lib/dynflow/utils/priority_queue.rb +1 -0
- data/lib/dynflow/version.rb +2 -1
- data/lib/dynflow/watchers/memory_consumption_watcher.rb +1 -0
- data/lib/dynflow/web.rb +1 -0
- data/lib/dynflow/web/console.rb +1 -0
- data/lib/dynflow/web/console_helpers.rb +1 -0
- data/lib/dynflow/web/filtering_helpers.rb +1 -0
- data/lib/dynflow/web/world_helpers.rb +1 -0
- data/lib/dynflow/web_console.rb +1 -0
- data/lib/dynflow/world.rb +11 -1
- data/lib/dynflow/world/invalidation.rb +7 -1
- data/test/abnormal_states_recovery_test.rb +41 -40
- data/test/action_test.rb +160 -110
- data/test/activejob_adapter_test.rb +1 -0
- data/test/batch_sub_tasks_test.rb +12 -11
- data/test/clock_test.rb +2 -1
- data/test/concurrency_control_test.rb +20 -19
- data/test/coordinator_test.rb +20 -21
- data/test/daemon_test.rb +2 -1
- data/test/dead_letter_silencer_test.rb +9 -7
- data/test/dispatcher_test.rb +2 -1
- data/test/execution_plan_cleaner_test.rb +13 -12
- data/test/execution_plan_hooks_test.rb +3 -2
- data/test/execution_plan_test.rb +33 -32
- data/test/executor_test.rb +533 -489
- data/test/future_execution_test.rb +45 -44
- data/test/memory_cosumption_watcher_test.rb +5 -4
- data/test/middleware_test.rb +55 -54
- data/test/persistence_test.rb +56 -53
- data/test/rescue_test.rb +36 -35
- data/test/round_robin_test.rb +13 -12
- data/test/semaphores_test.rb +31 -30
- data/test/support/code_workflow_example.rb +1 -0
- data/test/support/dummy_example.rb +14 -1
- data/test/support/middleware_example.rb +2 -1
- data/test/support/rails/config/environment.rb +1 -0
- data/test/support/rescue_example.rb +1 -0
- data/test/support/test_execution_log.rb +1 -0
- data/test/test_helper.rb +18 -17
- data/test/testing_test.rb +45 -44
- data/test/utils_test.rb +18 -17
- data/test/web_console_test.rb +1 -0
- data/test/world_test.rb +7 -6
- metadata +13 -4
- data/lib/dynflow/executors/abstract.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb02c56f3fda535ffdc29d64826470d8bb81cf4714ac98e8316dbcb0f045ce00
|
4
|
+
data.tar.gz: 7f0553a6e9bda6a5ae8d604f5f6238b52e5b6ad45462a3199c993a30e530f499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d3bdd0745db1d85f1be3c1c4510a54d167d175b48d33e8a89fbeaf7fa7c115f419a8756b89af4f2f4d57bad94a2bb1c999f8d6d9d530b850b7dab5a1638b042
|
7
|
+
data.tar.gz: 022b09ce7daa8ed8a2a856d5cc16f93c9375978d9fc571350dbaebe2c7c6381dadcc8c3510e6227c08872e85657ad8e27ebfbb3c70f5e0f1df61b946dfa3f4c1
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
language:
|
3
|
-
- ruby
|
1
|
+
language: ruby
|
4
2
|
|
5
3
|
services:
|
6
|
-
- mysql
|
7
4
|
- postgresql
|
8
5
|
|
9
6
|
rvm:
|
@@ -19,6 +16,8 @@ matrix:
|
|
19
16
|
include:
|
20
17
|
- rvm: "2.4.0"
|
21
18
|
env: "DB=mysql DB_CONN_STRING=mysql2://root@localhost/travis_ci_test"
|
19
|
+
services:
|
20
|
+
- mysql
|
22
21
|
- rvm: "2.4.0"
|
23
22
|
env: "DB=sqlite3 DB_CONN_STRING=sqlite:/"
|
24
23
|
- rvm: "2.4.0"
|
data/Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
FROM fedora:30
|
2
|
+
RUN dnf install -y curl git gcc gcc-c++ make openssl bzip2 findutils openssl-devel readline-devel \
|
3
|
+
zlib-devel sqlite-devel ruby ruby-devel rubygem-bundler redhat-rpm-config libpqxx-devel
|
4
|
+
|
5
|
+
ADD Gemfile /data/
|
6
|
+
ADD dynflow.gemspec /data/
|
7
|
+
ADD lib/dynflow/version.rb /data/lib/dynflow/version.rb
|
8
|
+
WORKDIR /data
|
9
|
+
RUN bundle install --without mysql
|
data/Gemfile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source 'https://rubygems.org'
|
2
3
|
|
3
4
|
gemspec
|
@@ -11,6 +12,11 @@ group :pry do
|
|
11
12
|
gem 'pry-byebug'
|
12
13
|
end
|
13
14
|
|
15
|
+
group :sidekiq do
|
16
|
+
gem 'sidekiq'
|
17
|
+
gem 'gitlab-sidekiq-fetcher', :require => 'sidekiq-reliable-fetch'
|
18
|
+
end
|
19
|
+
|
14
20
|
group :postgresql do
|
15
21
|
gem "pg"
|
16
22
|
end
|
data/Rakefile
CHANGED
data/doc/pages/Gemfile
CHANGED
data/doc/pages/Rakefile
CHANGED
data/doc/pages/plugins/play.rb
CHANGED
data/doc/pages/plugins/tags.rb
CHANGED
data/doc/pages/plugins/toc.rb
CHANGED
data/docker-compose.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
version: '3'
|
2
|
+
services:
|
3
|
+
postgres:
|
4
|
+
image: postgres:11-alpine
|
5
|
+
expose:
|
6
|
+
- 5432
|
7
|
+
environment:
|
8
|
+
- POSTGRES_PASSWORD=postgres
|
9
|
+
- POSTGRES_USER=postgres
|
10
|
+
- POSTGRES_DB=dynflow
|
11
|
+
redis:
|
12
|
+
image: redis:5.0.5-alpine
|
13
|
+
expose:
|
14
|
+
- 6379
|
15
|
+
client: &common
|
16
|
+
build: .
|
17
|
+
depends_on:
|
18
|
+
- postgres
|
19
|
+
- redis
|
20
|
+
environment:
|
21
|
+
- REDIS_URL=redis://redis:6379/0
|
22
|
+
- REDIS_PROVIDER=REDIS_URL
|
23
|
+
- DB_CONN_STRING=postgresql://postgres:postgres@postgres:5432/dynflow
|
24
|
+
volumes:
|
25
|
+
- ./:/data
|
26
|
+
command: |
|
27
|
+
ruby ./examples/remote_executor.rb client
|
28
|
+
observer:
|
29
|
+
<<: *common
|
30
|
+
command: |
|
31
|
+
ruby ./examples/remote_executor.rb observer
|
32
|
+
ports:
|
33
|
+
- 4567:4567
|
34
|
+
orchestrator:
|
35
|
+
<<: *common
|
36
|
+
command: |
|
37
|
+
sidekiq -r ./examples/remote_executor.rb -q dynflow_orchestrator -c 1
|
38
|
+
worker:
|
39
|
+
<<: *common
|
40
|
+
command: |
|
41
|
+
sidekiq -r ./examples/remote_executor.rb -q default
|
data/dynflow.gemspec
CHANGED
data/examples/clock_benchmark.rb
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
3
|
|
3
4
|
require 'dynflow'
|
4
5
|
|
5
6
|
class ExampleHelper
|
7
|
+
CONSOLE_URL='http://localhost:4567'
|
8
|
+
DYNFLOW_URL="#{CONSOLE_URL}/dynflow"
|
9
|
+
SIDEKIQ_URL="#{CONSOLE_URL}/sidekiq"
|
10
|
+
|
6
11
|
class << self
|
7
12
|
def world
|
8
13
|
@world ||= create_world
|
@@ -18,6 +23,7 @@ class ExampleHelper
|
|
18
23
|
config.logger_adapter = logger_adapter
|
19
24
|
config.auto_rescue = false
|
20
25
|
config.telemetry_adapter = telemetry_adapter
|
26
|
+
config.queues.add(:slow, :pool_size => 3)
|
21
27
|
yield config if block_given?
|
22
28
|
Dynflow::World.new(config).tap do |world|
|
23
29
|
puts "World #{world.id} started..."
|
@@ -41,7 +47,7 @@ class ExampleHelper
|
|
41
47
|
end
|
42
48
|
|
43
49
|
def logger_adapter
|
44
|
-
Dynflow::LoggerAdapters::Simple.new $stderr,
|
50
|
+
Dynflow::LoggerAdapters::Simple.new $stderr, Logger::FATAL
|
45
51
|
end
|
46
52
|
|
47
53
|
def run_web_console(world = ExampleHelper.world)
|
@@ -49,7 +55,18 @@ class ExampleHelper
|
|
49
55
|
dynflow_console = Dynflow::Web.setup do
|
50
56
|
set :world, world
|
51
57
|
end
|
52
|
-
|
58
|
+
apps = { '/dynflow' => dynflow_console }
|
59
|
+
puts "Starting Dynflow console at #{DYNFLOW_URL}"
|
60
|
+
begin
|
61
|
+
require 'sidekiq/web'
|
62
|
+
apps['/sidekiq'] = Sidekiq::Web
|
63
|
+
puts "Starting Sidekiq console at #{SIDEKIQ_URL}"
|
64
|
+
rescue LoadError
|
65
|
+
puts 'Sidekiq not around, not mounting the console'
|
66
|
+
end
|
67
|
+
|
68
|
+
app = Rack::URLMap.new(apps)
|
69
|
+
Rack::Server.new(:app => app, :Host => '0.0.0.0', :Port => URI.parse(CONSOLE_URL).port).start
|
53
70
|
end
|
54
71
|
|
55
72
|
# for simulation of the execution failing for the first time
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative 'example_helper'
|
4
5
|
|
@@ -64,7 +65,7 @@ if $0 == __FILE__
|
|
64
65
|
| #{near_future_plan.id} is delayed to execute at #{near_future} and should run successfully.
|
65
66
|
| #{future_plan.id} is delayed to execute at #{future} and should run successfully.
|
66
67
|
|
|
67
|
-
| Visit
|
68
|
+
| Visit #{ExampleHelper::DYNFLOW_URL} to see their status.
|
68
69
|
|
|
69
70
|
MSG
|
70
71
|
|
data/examples/orchestrate.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
example_description = <<DESC
|
4
5
|
Orchestrate Example
|
@@ -15,7 +16,7 @@ example_description = <<DESC
|
|
15
16
|
It also simulates a failure and demonstrates the Dynflow ability to rescue
|
16
17
|
from the error and consinue with the run.
|
17
18
|
|
18
|
-
Once the Sinatra web console starts, you can navigate to
|
19
|
+
Once the Sinatra web console starts, you can navigate to #{ExampleHelper::DYNFLOW_URL}
|
19
20
|
to see what's happening in the Dynflow world.
|
20
21
|
|
21
22
|
DESC
|
@@ -135,7 +136,7 @@ module Orchestrate
|
|
135
136
|
puts <<-MSG.gsub(/^.*\|/, '')
|
136
137
|
|
137
138
|
| Execution plan #{execution_plan_id} is failing
|
138
|
-
| You can resume it at
|
139
|
+
| You can resume it at #{ExampleHelper::DYNFLOW_URL}/#{execution_plan_id}
|
139
140
|
|
140
141
|
MSG
|
141
142
|
raise "temporary unavailabe"
|
@@ -148,9 +149,7 @@ module Orchestrate
|
|
148
149
|
end
|
149
150
|
|
150
151
|
if $0 == __FILE__
|
151
|
-
world = ExampleHelper.create_world
|
152
|
-
config.queues.add(:slow, :pool_size => 3)
|
153
|
-
end
|
152
|
+
world = ExampleHelper.create_world
|
154
153
|
ExampleHelper.set_world(world)
|
155
154
|
ExampleHelper.world.action_logger.level = Logger::INFO
|
156
155
|
ExampleHelper.something_should_fail!
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative 'example_helper'
|
4
5
|
|
@@ -17,7 +18,7 @@ example_description = <<DESC
|
|
17
18
|
send external events to the action while it's suspended. One use case is being
|
18
19
|
able to cancel the action while it's running.
|
19
20
|
|
20
|
-
Once the Sinatra web console starts, you can navigate to
|
21
|
+
Once the Sinatra web console starts, you can navigate to #{ExampleHelper::DYNFLOW_URL}
|
21
22
|
to see what's happening in the Dynflow world.
|
22
23
|
|
23
24
|
DESC
|
@@ -154,7 +155,7 @@ module OrchestrateEvented
|
|
154
155
|
|
155
156
|
| Execution plan #{execution_plan_id} got stuck
|
156
157
|
| You can cancel the stucked step at
|
157
|
-
|
|
158
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{execution_plan_id}
|
158
159
|
|
159
160
|
MSG
|
160
161
|
# we suspend the action but don't plan the wakeup event,
|
data/examples/remote_executor.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
# To run the observer:
|
6
|
+
#
|
7
|
+
# bundle exec ruby ./examples/remote_executor.rb observer
|
8
|
+
#
|
9
|
+
# To run the server:
|
10
|
+
#
|
11
|
+
# bundle exec ruby ./examples/remote_executor.rb server
|
12
|
+
#
|
13
|
+
# To run the client:
|
14
|
+
#
|
15
|
+
# bundle exec ruby ./examples/remote_executor.rb client
|
16
|
+
#
|
17
|
+
# Sidekiq
|
18
|
+
# =======
|
19
|
+
#
|
20
|
+
# In case of using Sidekiq as async job backend, use this instead of the server command
|
21
|
+
#
|
22
|
+
# To run the orchestrator:
|
23
|
+
#
|
24
|
+
# bundle exec sidekiq -r ./examples/remote_executor.rb -q dynflow_orchestrator
|
25
|
+
#
|
26
|
+
# To run the worker:
|
27
|
+
#
|
28
|
+
# bundle exec sidekiq -r ./examples/remote_executor.rb -q default
|
3
29
|
|
4
30
|
require_relative 'example_helper'
|
5
31
|
require_relative 'orchestrate_evented'
|
@@ -37,6 +63,34 @@ class RemoteExecutorExample
|
|
37
63
|
run(world)
|
38
64
|
end
|
39
65
|
|
66
|
+
def initialize_sidekiq_orchestrator
|
67
|
+
ExampleHelper.create_world do |config|
|
68
|
+
config.persistence_adapter = persistence_adapter
|
69
|
+
config.connector = connector
|
70
|
+
config.executor = ::Dynflow::Executors::Sidekiq::Core
|
71
|
+
config.auto_validity_check = false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def initialize_sidekiq_worker
|
76
|
+
Sidekiq.configure_server do |config|
|
77
|
+
require 'sidekiq-reliable-fetch'
|
78
|
+
# Use semi-reliable fetch
|
79
|
+
# for details see https://gitlab.com/gitlab-org/sidekiq-reliable-fetch/blob/master/README.md
|
80
|
+
config.options[:semi_reliable_fetch] = true
|
81
|
+
# Do not requeue jobs after sidekiq shutdown
|
82
|
+
config.options[:max_retries_after_interruption] = 0
|
83
|
+
# Do not store interrupted jobs, just discard them
|
84
|
+
config.options[:interrupted_max_jobs] = 0
|
85
|
+
Sidekiq::ReliableFetch.setup_reliable_fetch!(config)
|
86
|
+
end
|
87
|
+
ExampleHelper.create_world do |config|
|
88
|
+
config.persistence_adapter = persistence_adapter
|
89
|
+
config.connector = connector
|
90
|
+
config.executor = false
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
40
94
|
def run(world)
|
41
95
|
begin
|
42
96
|
ExampleHelper.run_web_console(world)
|
@@ -75,7 +129,10 @@ class RemoteExecutorExample
|
|
75
129
|
world.trigger(OrchestrateEvented::CreateInfrastructure, true)
|
76
130
|
|
77
131
|
loop do
|
132
|
+
start_time = Time.now
|
78
133
|
world.trigger(SampleAction).finished.wait
|
134
|
+
finished_in = Time.now - start_time
|
135
|
+
puts "Finished in #{finished_in}s"
|
79
136
|
sleep 0.5
|
80
137
|
end
|
81
138
|
end
|
@@ -106,4 +163,15 @@ MSG
|
|
106
163
|
puts "Unknown command #{comment}"
|
107
164
|
exit 1
|
108
165
|
end
|
166
|
+
elsif defined?(Sidekiq)
|
167
|
+
# TODO:
|
168
|
+
Sidekiq.default_worker_options = { :retry => 0, 'backtrace' => true }
|
169
|
+
# assuming the remote executor was required as part of initialization
|
170
|
+
# of the ActiveJob worker
|
171
|
+
world = if Sidekiq.options[:queues].include?("dynflow_orchestrator")
|
172
|
+
RemoteExecutorExample.initialize_sidekiq_orchestrator
|
173
|
+
elsif (Sidekiq.options[:queues] - ['dynflow_orchestrator']).any?
|
174
|
+
RemoteExecutorExample.initialize_sidekiq_worker
|
175
|
+
end
|
176
|
+
Sidekiq.options[:dynflow_world] = world
|
109
177
|
end
|
data/examples/singletons.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
example_description = <<DESC
|
3
4
|
|
4
5
|
Sub Plans Example
|
@@ -44,9 +45,9 @@ if $0 == __FILE__
|
|
44
45
|
| #{t2.id} should fail because #{t1.id} holds the lock
|
45
46
|
|
|
46
47
|
| You can see the details at
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{t1.id}
|
49
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{t2.id}
|
50
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{t3.id}
|
50
51
|
|
|
51
52
|
MSG
|
52
53
|
ExampleHelper.run_web_console
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
example_description = <<DESC
|
4
5
|
Sub-plan Concurrency Control Example
|
@@ -62,7 +63,7 @@ if $0 == __FILE__
|
|
62
63
|
puts example_description
|
63
64
|
puts <<-MSG.gsub(/^.*\|/, '')
|
64
65
|
| Execution plan #{triggered.id} with 10 sub plans triggered
|
65
|
-
| You can see the details at
|
66
|
+
| You can see the details at #{ExampleHelper::DYNFLOW_URL}/#{triggered.id}/actions/1/sub_plans
|
66
67
|
| Or simply watch in the console that there are never more than #{ConcurrencyControlExample::ConcurrencyLevel} running at the same time.
|
67
68
|
|
|
68
69
|
| The tasks are distributed over #{ConcurrencyControlExample::RunWithin} seconds.
|
data/examples/sub_plans.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
example_description = <<DESC
|
3
4
|
Sub Plans Example
|
4
5
|
===================
|
@@ -51,8 +52,8 @@ if $0 == __FILE__
|
|
51
52
|
puts <<-MSG.gsub(/^.*\|/, '')
|
52
53
|
| Execution plans #{t1.id} and #{t2.id} with sub plans triggered
|
53
54
|
| You can see the details at
|
54
|
-
|
|
55
|
-
|
|
55
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{t2.id}
|
56
|
+
| #{ExampleHelper::DYNFLOW_URL}/#{t1.id}
|
56
57
|
MSG
|
57
58
|
|
58
59
|
ExampleHelper.run_web_console
|