smart_proxy_dynflow_core 0.3.0 → 0.3.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e99a82c7e0d25bbf1e386b234423881d4742f14e243fb68dfcafa6a625a47b44
|
4
|
+
data.tar.gz: a5ca245cf3085f1f4d24631d7ce6a45fc08419e5455116a6f8e3e2a4621138a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4422e274f8672c7cbe8ba3dcdc33ea2568f5a25661de0f11fffedd70e75b0c9e29078b84e8162f467ff750b9f71028d20d2231931443b84a8140f7bce89774d
|
7
|
+
data.tar.gz: af183777ce4813da50fc734fcf8f6e873093d2d3e1b051f7e5d2e9b64d4d2d40e1a3adaa5626fec188c3577253fd7e068a056bbb85ad295f22171db5b8995ca6
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Actions
|
2
|
+
module Middleware
|
3
|
+
class KeepCurrentRequestID < Dynflow::Middleware
|
4
|
+
def delay(*args)
|
5
|
+
pass(*args).tap { store_current_request_id }
|
6
|
+
end
|
7
|
+
|
8
|
+
def plan(*args)
|
9
|
+
with_current_request_id do
|
10
|
+
pass(*args).tap { store_current_request_id }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(*args)
|
15
|
+
restore_current_request_id { pass(*args) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def finalize
|
19
|
+
restore_current_request_id { pass }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Run all execution plan lifecycle hooks as the original request_id
|
23
|
+
def hook(*args)
|
24
|
+
restore_current_request_id { pass(*args) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def with_current_request_id
|
30
|
+
if action.input[:current_request_id].nil?
|
31
|
+
yield
|
32
|
+
else
|
33
|
+
restore_current_request_id { yield }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def store_current_request_id
|
38
|
+
action.input[:current_request_id] = ::Logging.mdc['request']
|
39
|
+
end
|
40
|
+
|
41
|
+
def restore_current_request_id
|
42
|
+
unless (restored_id = action.input[:current_request_id]).nil?
|
43
|
+
old_id = ::Logging.mdc['request']
|
44
|
+
if !old_id.nil? && old_id != restored_id
|
45
|
+
action.action_logger.warn('Changing request id %{request_id} to saved id %{saved_id}' % { :saved_id => restored_id, :request_id => old_id })
|
46
|
+
end
|
47
|
+
::Logging.mdc['request'] = restored_id
|
48
|
+
end
|
49
|
+
yield
|
50
|
+
ensure
|
51
|
+
# Reset to original request id only when not nil
|
52
|
+
# Otherwise, keep the id until it's cleaned in Dynflow's run_user_code block
|
53
|
+
# so that it will stay valid for the rest of the processing of the current step
|
54
|
+
# (even outside of the middleware lifecycle)
|
55
|
+
::Logging.mdc['request'] = old_id unless old_id.nil?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
|
16
16
|
gem.executables = ['smart_proxy_dynflow_core']
|
17
17
|
gem.files = Dir['lib/smart_proxy_dynflow_core.rb', 'config/settings.yml.example',
|
18
|
-
'lib/smart_proxy_dynflow_core
|
18
|
+
'lib/smart_proxy_dynflow_core/**/*', 'LICENSE', 'Gemfile',
|
19
19
|
'bin/smart_proxy_dynflow_core', 'deploy/*', 'smart_proxy_dynflow_core.gemspec']
|
20
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
21
|
gem.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dynflow_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- lib/smart_proxy_dynflow_core/launcher.rb
|
244
244
|
- lib/smart_proxy_dynflow_core/log.rb
|
245
245
|
- lib/smart_proxy_dynflow_core/logger_middleware.rb
|
246
|
+
- lib/smart_proxy_dynflow_core/middleware/keep_current_request_id.rb
|
246
247
|
- lib/smart_proxy_dynflow_core/request_id_middleware.rb
|
247
248
|
- lib/smart_proxy_dynflow_core/settings.rb
|
248
249
|
- lib/smart_proxy_dynflow_core/task_launcher_registry.rb
|