smart_proxy_dynflow 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6673ce798c24b310ce2b132ac1c07cddbdfbd49ac9b0dd8e0e8abbc0312b2a0c
4
- data.tar.gz: b966221317f31e9e32ba85a77d8f26c64ae238d35d99548da8e9647da5b092a5
3
+ metadata.gz: d19598abd3ab23ee44430f2e5c2207c6ac11d9c7919769ed5885408ee2e39f1c
4
+ data.tar.gz: 39d351c883a1f3c5d9402462961591d7bd4bd70e4ae0ca04d8c7095a710c70d2
5
5
  SHA512:
6
- metadata.gz: e05968e12c48d7b997d60231cc541d4bb0ae13a3f2ba8a1b586af0a0a1232086cd09cceb5b49e10deb68bd8dfe65817a925b09a44f022126a7695316532bf89d
7
- data.tar.gz: ea263ed0aa2e2ca216c85385c7ec00e66cca6df6ca569cc6dda67f98fe1c5ef0d30eea3510b6227fdc69f61a9619b949265bd2f286a036a8d3f09520ed004326
6
+ metadata.gz: a557af273f69dda522cd9236d4f99cce270fd66d71c3b09150df6ba37eecbb0ddd2663e670b81c5ba806dd1af6927740c66f70b02551a42468d8e39f296f9e0f
7
+ data.tar.gz: 37a46da28658e4b26eceb19a86bdd2849cc387caf004213166bfd16580ec603a3f035fe797a7892423fad9e97129fcfeb95c82a789522d3088bf2a0dc3a3eefd
@@ -0,0 +1 @@
1
+ # gem 'inspect_anything'
@@ -0,0 +1 @@
1
+ # gem 'dynflow', :path => '../dynflow'
@@ -3,15 +3,16 @@ module Proxy::Dynflow::Action
3
3
  include Dynflow::Action::WithSubPlans
4
4
  include Dynflow::Action::WithPollingSubPlans
5
5
 
6
- # { task_id => { :action_class => Klass, :input => input } }
6
+ # { execution_plan_uuid => { :action_class => Klass, :input => input } }
7
7
  def plan(launcher, input_hash)
8
- launcher.launch_children(self, input_hash)
9
- plan_self
8
+ plan_self :input_hash => input_hash,
9
+ :launcher => launcher.to_hash
10
10
  end
11
11
 
12
- def initiate
13
- ping suspended_action
14
- wait_for_sub_plans sub_plans
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
- plan_self :targets => input_hash, :results => results
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
@@ -0,0 +1,17 @@
1
+ module Proxy::Dynflow::Action
2
+ module WithExternalPolling
3
+ Poll = Algebrick.atom
4
+
5
+ def run(event = nil)
6
+ if event.is_a?(Poll)
7
+ poll
8
+ suspend
9
+ else
10
+ super
11
+ end
12
+ end
13
+
14
+ def poll
15
+ end
16
+ end
17
+ end
@@ -1,20 +1,8 @@
1
1
  module Proxy::Dynflow::Action
2
2
  class SingleRunnerBatch < Batch
3
3
  def plan(launcher, input_hash)
4
- launcher.launch_children(self, input_hash)
5
- sequence do
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)
@@ -11,9 +11,11 @@ module Proxy::Dynflow
11
11
  settings_file "dynflow.yml"
12
12
  requires :foreman_proxy, ">= 1.16.0"
13
13
  default_settings :console_auth => true,
14
- :execution_plan_cleaner_age => 60 * 30
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, Proxy::Dynflow::Action::Batch, self, input)
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.each do |task_id, input|
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
- success_tasks = input_hash.select do |task_id, _input|
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
@@ -7,8 +7,8 @@ module Proxy::Dynflow
7
7
  raise NotImplementedError
8
8
  end
9
9
 
10
- def launch!(input)
11
- trigger(nil, Action::SingleRunnerBatch, self, input)
10
+ def action_class
11
+ Action::SingleRunnerBatch
12
12
  end
13
13
 
14
14
  def launch_children(parent, input_hash)
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Dynflow
3
- VERSION = '0.6.3'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  end
5
5
  end
@@ -6,5 +6,5 @@
6
6
  # :console_auth: true
7
7
 
8
8
  # Maximum age of execution plans to keep before having them cleaned
9
- # by the execution plan cleaner (in seconds), defaults to 30 minutes
10
- # :execution_plan_cleaner_age: 1800
9
+ # by the execution plan cleaner (in seconds), defaults to 24 hours
10
+ # :execution_plan_cleaner_age: 86400
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.6.3
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: 1980-01-01 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow
@@ -146,11 +146,14 @@ files:
146
146
  - Gemfile
147
147
  - LICENSE
148
148
  - bundler.d/dynflow.rb
149
+ - bundler.d/inspect_anything.rb
150
+ - bundler.d/x.local.rb
149
151
  - lib/smart_proxy_dynflow.rb
150
152
  - lib/smart_proxy_dynflow/action.rb
151
153
  - lib/smart_proxy_dynflow/action/batch.rb
152
154
  - lib/smart_proxy_dynflow/action/batch_callback.rb
153
155
  - lib/smart_proxy_dynflow/action/batch_runner.rb
156
+ - lib/smart_proxy_dynflow/action/external_polling.rb
154
157
  - lib/smart_proxy_dynflow/action/output_collector.rb
155
158
  - lib/smart_proxy_dynflow/action/runner.rb
156
159
  - lib/smart_proxy_dynflow/action/shareable.rb
@@ -165,6 +168,7 @@ files:
165
168
  - lib/smart_proxy_dynflow/middleware/keep_current_request_id.rb
166
169
  - lib/smart_proxy_dynflow/otp_manager.rb
167
170
  - lib/smart_proxy_dynflow/plugin.rb
171
+ - lib/smart_proxy_dynflow/process_manager.rbs
168
172
  - lib/smart_proxy_dynflow/proxy_adapter.rb
169
173
  - lib/smart_proxy_dynflow/runner.rb
170
174
  - lib/smart_proxy_dynflow/runner/base.rb
@@ -204,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
208
  - !ruby/object:Gem::Version
205
209
  version: '0'
206
210
  requirements: []
207
- rubygems_version: 3.2.26
211
+ rubygems_version: 3.1.2
208
212
  signing_key:
209
213
  specification_version: 4
210
214
  summary: Dynflow runtime for Foreman smart proxy