smart_proxy_dynflow 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_proxy_dynflow/action/batch.rb +7 -6
- data/lib/smart_proxy_dynflow/action/batch_callback.rb +6 -1
- data/lib/smart_proxy_dynflow/action/external_polling.rb +17 -0
- data/lib/smart_proxy_dynflow/action/runner.rb +1 -1
- data/lib/smart_proxy_dynflow/action/single_runner_batch.rb +2 -14
- data/lib/smart_proxy_dynflow/plugin.rb +6 -0
- data/lib/smart_proxy_dynflow/process_manager.rbs +46 -0
- data/lib/smart_proxy_dynflow/task_launcher/abstract.rb +10 -2
- data/lib/smart_proxy_dynflow/task_launcher/batch.rb +12 -11
- data/lib/smart_proxy_dynflow/task_launcher/group.rb +2 -2
- data/lib/smart_proxy_dynflow/task_launcher/single.rb +3 -2
- data/lib/smart_proxy_dynflow/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d19598abd3ab23ee44430f2e5c2207c6ac11d9c7919769ed5885408ee2e39f1c
|
4
|
+
data.tar.gz: 39d351c883a1f3c5d9402462961591d7bd4bd70e4ae0ca04d8c7095a710c70d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a557af273f69dda522cd9236d4f99cce270fd66d71c3b09150df6ba37eecbb0ddd2663e670b81c5ba806dd1af6927740c66f70b02551a42468d8e39f296f9e0f
|
7
|
+
data.tar.gz: 37a46da28658e4b26eceb19a86bdd2849cc387caf004213166bfd16580ec603a3f035fe797a7892423fad9e97129fcfeb95c82a789522d3088bf2a0dc3a3eefd
|
@@ -3,15 +3,16 @@ module Proxy::Dynflow::Action
|
|
3
3
|
include Dynflow::Action::WithSubPlans
|
4
4
|
include Dynflow::Action::WithPollingSubPlans
|
5
5
|
|
6
|
-
# {
|
6
|
+
# { execution_plan_uuid => { :action_class => Klass, :input => input } }
|
7
7
|
def plan(launcher, input_hash)
|
8
|
-
|
9
|
-
|
8
|
+
plan_self :input_hash => input_hash,
|
9
|
+
:launcher => launcher.to_hash
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
12
|
+
def create_sub_plans
|
13
|
+
Proxy::Dynflow::TaskLauncher::Abstract
|
14
|
+
.new_from_hash(world, input[:launcher])
|
15
|
+
.launch_children(self, input[:input_hash])
|
15
16
|
end
|
16
17
|
|
17
18
|
def rescue_strategy
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Proxy::Dynflow::Action
|
2
2
|
class BatchCallback < ::Dynflow::Action
|
3
3
|
def plan(input_hash, results)
|
4
|
-
|
4
|
+
# In input_hash there are complete inputs for all the actions for which this is reporting
|
5
|
+
# Trim it down to only the bare minimum we actually need
|
6
|
+
callbacks = input_hash.reduce({}) do |acc, (key, value)|
|
7
|
+
acc.merge(key => value['action_input']['callback'])
|
8
|
+
end
|
9
|
+
plan_self :targets => callbacks, :results => results
|
5
10
|
end
|
6
11
|
|
7
12
|
def run
|
@@ -1,20 +1,8 @@
|
|
1
1
|
module Proxy::Dynflow::Action
|
2
2
|
class SingleRunnerBatch < Batch
|
3
3
|
def plan(launcher, input_hash)
|
4
|
-
|
5
|
-
|
6
|
-
results = plan_self
|
7
|
-
plan_action BatchCallback, launcher.prepare_batch(input_hash), results.output[:results]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def run(event = nil)
|
12
|
-
super unless event == Dynflow::Action::Skip
|
13
|
-
end
|
14
|
-
|
15
|
-
def initiate
|
16
|
-
ping suspended_action
|
17
|
-
wait_for_sub_plans sub_plans
|
4
|
+
results = super
|
5
|
+
plan_action BatchCallback, input_hash, results.output[:results]
|
18
6
|
end
|
19
7
|
|
20
8
|
def check_for_errors!(optional = true)
|
@@ -14,6 +14,8 @@ module Proxy::Dynflow
|
|
14
14
|
:execution_plan_cleaner_age => 60 * 60 * 24
|
15
15
|
plugin :dynflow, Proxy::Dynflow::VERSION
|
16
16
|
|
17
|
+
capability(proc { self.available_operations })
|
18
|
+
|
17
19
|
after_activation do
|
18
20
|
require 'smart_proxy_dynflow/settings_loader'
|
19
21
|
require 'smart_proxy_dynflow/otp_manager'
|
@@ -25,5 +27,9 @@ module Proxy::Dynflow
|
|
25
27
|
|
26
28
|
Proxy::Dynflow::Core.ensure_initialized
|
27
29
|
end
|
30
|
+
|
31
|
+
def self.available_operations
|
32
|
+
TaskLauncherRegistry.operations
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# TypeProf 0.21.2
|
2
|
+
|
3
|
+
# Classes
|
4
|
+
module Proxy
|
5
|
+
module Dynflow
|
6
|
+
class IOBuffer
|
7
|
+
@callback: nil
|
8
|
+
|
9
|
+
attr_accessor io: nil
|
10
|
+
attr_reader buffer: String
|
11
|
+
def initialize: (nil io) -> void
|
12
|
+
def on_data: -> nil
|
13
|
+
def to_io: -> IO
|
14
|
+
def to_s: -> String
|
15
|
+
def empty?: -> bool
|
16
|
+
def closed?: -> untyped
|
17
|
+
def close: -> nil
|
18
|
+
def read_available!: -> nil
|
19
|
+
def write_available!: -> nil
|
20
|
+
def add_data: (untyped data) -> String
|
21
|
+
|
22
|
+
private
|
23
|
+
def with_callback: (String? data) -> String?
|
24
|
+
end
|
25
|
+
|
26
|
+
class ProcessManager
|
27
|
+
@command: untyped
|
28
|
+
|
29
|
+
attr_reader stdin: IOBuffer
|
30
|
+
attr_reader stdout: IOBuffer
|
31
|
+
attr_reader stderr: IOBuffer
|
32
|
+
attr_reader pid: Integer
|
33
|
+
attr_reader status: Integer?
|
34
|
+
def initialize: (untyped command) -> void
|
35
|
+
def run!: -> ProcessManager
|
36
|
+
def start!: -> String
|
37
|
+
def started?: -> bool
|
38
|
+
def done?: -> bool
|
39
|
+
def close: -> [IOBuffer, IOBuffer, IOBuffer]
|
40
|
+
def process: (?timeout: nil) -> Array[untyped]?
|
41
|
+
def finish: -> Integer?
|
42
|
+
def on_stdout: -> nil
|
43
|
+
def on_stderr: -> nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -15,6 +15,14 @@ module Proxy::Dynflow
|
|
15
15
|
|
16
16
|
def self.input_format; end
|
17
17
|
|
18
|
+
def to_hash
|
19
|
+
{ :class => self.class.to_s, :callback => callback, :options => options }
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.new_from_hash(world, hash)
|
23
|
+
::Dynflow::Utils.constantize(hash[:class]).new(world, hash[:callback], hash[:options])
|
24
|
+
end
|
25
|
+
|
18
26
|
private
|
19
27
|
|
20
28
|
def format_result(result)
|
@@ -34,9 +42,9 @@ module Proxy::Dynflow
|
|
34
42
|
input.merge(:callback_host => callback)
|
35
43
|
end
|
36
44
|
|
37
|
-
def trigger(parent, klass, *input)
|
45
|
+
def trigger(parent, klass, *input, id: nil)
|
38
46
|
world.trigger do
|
39
|
-
world.plan_with_options(caller_action: parent, action_class: klass, args: input)
|
47
|
+
world.plan_with_options(caller_action: parent, action_class: klass, args: input, id: id)
|
40
48
|
end
|
41
49
|
end
|
42
50
|
end
|
@@ -2,36 +2,37 @@ module Proxy::Dynflow
|
|
2
2
|
module TaskLauncher
|
3
3
|
class Batch < Abstract
|
4
4
|
def launch!(input)
|
5
|
-
trigger(nil,
|
5
|
+
plan = trigger(nil, action_class, self, input)
|
6
|
+
results[:parent] = format_result(plan)
|
6
7
|
end
|
7
8
|
|
8
9
|
def launch_children(parent, input_hash)
|
9
|
-
input_hash.
|
10
|
+
input_hash.map do |task_id, input|
|
10
11
|
launcher = child_launcher(parent)
|
11
|
-
launcher.launch!(transform_input(input))
|
12
|
+
triggered = launcher.launch!(transform_input(input), id: task_id)
|
12
13
|
results[task_id] = launcher.results
|
14
|
+
triggered
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def prepare_batch(input_hash)
|
17
|
-
|
18
|
-
results[task_id][:result] == 'success'
|
19
|
-
end
|
20
|
-
success_tasks.reduce({}) do |acc, (key, value)|
|
21
|
-
acc.merge(results[key][:task_id] => value['action_input']['callback'])
|
22
|
-
end
|
19
|
+
input_hash
|
23
20
|
end
|
24
21
|
|
25
|
-
private
|
26
|
-
|
27
22
|
def child_launcher(parent)
|
28
23
|
Single.new(world, callback, :parent => parent)
|
29
24
|
end
|
30
25
|
|
26
|
+
private
|
27
|
+
|
31
28
|
# Identity by default
|
32
29
|
def transform_input(input)
|
33
30
|
input
|
34
31
|
end
|
32
|
+
|
33
|
+
def action_class
|
34
|
+
Proxy::Dynflow::Action::Batch
|
35
|
+
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -5,10 +5,11 @@ module Proxy::Dynflow
|
|
5
5
|
{ :action_class => "MyActionClass", :action_input => {} }
|
6
6
|
end
|
7
7
|
|
8
|
-
def launch!(input)
|
8
|
+
def launch!(input, id: nil)
|
9
9
|
triggered = trigger(options[:parent],
|
10
10
|
action_class(input),
|
11
|
-
with_callback(input.fetch('action_input', {}))
|
11
|
+
with_callback(input.fetch('action_input', {})),
|
12
|
+
id: id)
|
12
13
|
@results = format_result(triggered)
|
13
14
|
triggered
|
14
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dynflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- lib/smart_proxy_dynflow/action/batch.rb
|
154
154
|
- lib/smart_proxy_dynflow/action/batch_callback.rb
|
155
155
|
- lib/smart_proxy_dynflow/action/batch_runner.rb
|
156
|
+
- lib/smart_proxy_dynflow/action/external_polling.rb
|
156
157
|
- lib/smart_proxy_dynflow/action/output_collector.rb
|
157
158
|
- lib/smart_proxy_dynflow/action/runner.rb
|
158
159
|
- lib/smart_proxy_dynflow/action/shareable.rb
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- lib/smart_proxy_dynflow/middleware/keep_current_request_id.rb
|
168
169
|
- lib/smart_proxy_dynflow/otp_manager.rb
|
169
170
|
- lib/smart_proxy_dynflow/plugin.rb
|
171
|
+
- lib/smart_proxy_dynflow/process_manager.rbs
|
170
172
|
- lib/smart_proxy_dynflow/proxy_adapter.rb
|
171
173
|
- lib/smart_proxy_dynflow/runner.rb
|
172
174
|
- lib/smart_proxy_dynflow/runner/base.rb
|