trailblazer-activity 0.7.0 → 0.7.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 511b5b1197ad392755eaf1fb930a5b6080561ef25e85199ac1afecdeeeafc998
|
4
|
+
data.tar.gz: 58cae3a0c236f26a9f05a671b75618d51ff5075422e7eb796be3b4230a25fe17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4123c5d0e4647a683f16811e36beba43ca4f88cd5abd6e325b8a340961c7a219d90aa9ba73543aa9dd0d21a4eebb7b13925d227036b5f12a30e5ca2ec1bff966
|
7
|
+
data.tar.gz: a463bcf78493d8f31f13141a66be05f260d95f7c7f55af0e7f0aa58be0a59b5585c4ffbaadee78c465ca807f9d21788f4c98dc195b19538f74c973b29b5cd2af
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.7.1
|
2
|
+
|
3
|
+
* Alias `Trace.call` to `Trace.invoke` for consistency.
|
4
|
+
* Allow injecting your own stack into `Trace.invoke`. This enables us to provide tracing even when there's an exception (due to, well, mutability).
|
5
|
+
* Minor changes in `Trace::Present` so that "unfinished" stacks can also be rendered.
|
6
|
+
* `Trace::Present.tree` is now private and superseded by `Present.call`.
|
7
|
+
|
1
8
|
# 0.7.0
|
2
9
|
|
3
10
|
* Remove `DSL::Helper`, "helper" methods now sit directly in the `DSL` namespace.
|
@@ -2,38 +2,56 @@ require "hirb"
|
|
2
2
|
|
3
3
|
module Trailblazer
|
4
4
|
class Activity < Module
|
5
|
+
|
6
|
+
# Task < Array
|
7
|
+
# [ input, ..., output ]
|
8
|
+
|
5
9
|
module Trace
|
6
10
|
# TODO: make this simpler.
|
7
11
|
module Present
|
8
12
|
module_function
|
9
13
|
|
10
|
-
def
|
14
|
+
def call(stack, level=1, tree=[])
|
15
|
+
tree(stack.to_a, level, tree)
|
16
|
+
end
|
17
|
+
|
18
|
+
def tree(stack, level, tree)
|
11
19
|
tree_for(stack, level, tree)
|
12
20
|
|
13
21
|
Hirb::Console.format_output(tree, class: :tree, type: :directory)
|
14
22
|
end
|
15
23
|
|
16
24
|
def tree_for(stack, level, tree)
|
17
|
-
stack.each do |
|
18
|
-
|
25
|
+
stack.each do |task| # always a Stack::Task[input, ..., output]
|
26
|
+
input, output, nested = input_output_nested_for_task(task)
|
27
|
+
|
28
|
+
task = input.task
|
19
29
|
|
20
|
-
graph = Introspect::Graph(
|
30
|
+
graph = Introspect::Graph(input.activity)
|
21
31
|
|
22
32
|
name = (node = graph.find { |node| node[:task] == task }) ? node[:id] : task
|
23
33
|
name ||= task # FIXME: bullshit
|
24
34
|
|
25
|
-
|
26
|
-
tree << [ level, name ]
|
27
|
-
else # nesting
|
28
|
-
tree << [ level, name ]
|
35
|
+
tree << [ level, name ]
|
29
36
|
|
30
|
-
|
37
|
+
if nested.any? # nesting
|
38
|
+
tree_for(nested, level + 1, tree)
|
31
39
|
end
|
32
40
|
|
33
41
|
tree
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
45
|
+
# DISCUSS: alternatively, we can have Task<input: output: data: >
|
46
|
+
def input_output_nested_for_task(task)
|
47
|
+
input = task[0]
|
48
|
+
output = task[-1]
|
49
|
+
|
50
|
+
output, nested = output.is_a?(Entity::Output) ? [output, task-[input, output]] : [nil, task[1..-1]]
|
51
|
+
|
52
|
+
return input, output, nested
|
53
|
+
end
|
54
|
+
|
37
55
|
def to_name(debug_item)
|
38
56
|
track = debug_item[2]
|
39
57
|
klass = track.class == Class ? track : track.class
|
@@ -17,9 +17,9 @@ class Trailblazer::Activity < Module
|
|
17
17
|
def capture_return((wrap_config, original_args), **circuit_options)
|
18
18
|
(original_options, original_flow_options, _) = original_args[0]
|
19
19
|
|
20
|
-
original_flow_options[:stack] << Trailblazer::Activity::Trace::Entity.new(
|
21
|
-
wrap_config[:task], {},
|
22
|
-
)
|
20
|
+
original_flow_options[:stack] << Trailblazer::Activity::Trace::Entity::Output.new(
|
21
|
+
wrap_config[:task], {}, wrap_config[:return_signal]
|
22
|
+
).freeze
|
23
23
|
|
24
24
|
original_flow_options[:stack].unindent!
|
25
25
|
|
@@ -33,9 +33,9 @@ class Trailblazer::Activity < Module
|
|
33
33
|
def capture_for(task, (ctx, flow), activity:, **circuit_options)
|
34
34
|
flow[:stack].indent!
|
35
35
|
|
36
|
-
flow[:stack] << Trailblazer::Activity::Trace::Entity.new(
|
37
|
-
task, activity
|
38
|
-
)
|
36
|
+
flow[:stack] << Trailblazer::Activity::Trace::Entity::Input.new(
|
37
|
+
task, activity
|
38
|
+
).freeze
|
39
39
|
|
40
40
|
return [ctx, flow], circuit_options.merge(activity: activity)
|
41
41
|
end
|
@@ -5,47 +5,63 @@ module Trailblazer
|
|
5
5
|
# stack, _ = Trailblazer::Activity::Trace.(activity, activity[:Start], { id: 1 })
|
6
6
|
# puts Trailblazer::Activity::Present.tree(stack) # renders the trail.
|
7
7
|
#
|
8
|
-
# Hooks into the
|
8
|
+
# Hooks into the taskWrap.
|
9
9
|
module Trace
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
tracing_circuit_options = {
|
19
|
-
wrap_runtime: ::Hash.new(Trace.wirings), # FIXME: this still overrides existing :wrap_runtime.
|
20
|
-
}
|
21
|
-
|
22
|
-
return activity, [ options, flow_options.merge(tracing_flow_options) ], circuit_options.merge(tracing_circuit_options)
|
23
|
-
end
|
10
|
+
class << self
|
11
|
+
# {:argumenter} API
|
12
|
+
# FIXME: needs Introspect.arguments_for_call
|
13
|
+
# FIXME: needs TaskWrap.arguments_for_call
|
14
|
+
def arguments_for_call(activity, (options, flow_options), **circuit_options)
|
15
|
+
tracing_flow_options = {
|
16
|
+
stack: Trace::Stack.new,
|
17
|
+
}
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Activity::TaskWrap.invoke(activity, [options, flow_options], circuit_options)
|
19
|
+
tracing_circuit_options = {
|
20
|
+
wrap_runtime: ::Hash.new(Trace.wirings), # FIXME: this still overrides existing :wrap_runtime.
|
21
|
+
}
|
29
22
|
|
30
|
-
|
31
|
-
|
23
|
+
return activity, [ options, tracing_flow_options.merge(flow_options) ], circuit_options.merge(tracing_circuit_options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(activity, (options, flow_options), circuit_options={})
|
27
|
+
activity, (options, flow_options), circuit_options = Trace.arguments_for_call( activity, [options, flow_options], circuit_options ) # only run once for the entire circuit!
|
28
|
+
|
29
|
+
last_signal, (options, flow_options) =
|
30
|
+
Activity::TaskWrap.invoke(activity, [options, flow_options], circuit_options)
|
31
|
+
|
32
|
+
return flow_options[:stack], last_signal, [options, flow_options]
|
33
|
+
end
|
32
34
|
|
33
|
-
|
35
|
+
alias_method :invoke, :call
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
# Insertions for the trace tasks that capture the arguments just before calling the task,
|
38
|
+
# and before the TaskWrap is finished.
|
39
|
+
#
|
40
|
+
# Note that the TaskWrap steps are implemented in Activity::TaskWrap::Trace.
|
41
|
+
#
|
42
|
+
# @private
|
43
|
+
def wirings
|
44
|
+
Module.new do
|
45
|
+
extend Activity::Path::Plan()
|
42
46
|
|
43
|
-
|
44
|
-
|
47
|
+
task TaskWrap::Trace.method(:capture_args), id: "task_wrap.capture_args", before: "task_wrap.call_task"
|
48
|
+
task TaskWrap::Trace.method(:capture_return), id: "task_wrap.capture_return", before: "End.success", group: :end
|
49
|
+
end
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
48
|
-
Entity = Struct.new(:task, :activity, :
|
53
|
+
Entity = Struct.new(:task, :activity, :data)
|
54
|
+
class Entity::Input < Entity
|
55
|
+
end
|
56
|
+
|
57
|
+
class Entity::Output < Entity
|
58
|
+
end
|
59
|
+
|
60
|
+
class Task < Array
|
61
|
+
def inspect
|
62
|
+
%{<Task>#{super}}
|
63
|
+
end
|
64
|
+
end
|
49
65
|
|
50
66
|
# Mutable/stateful per design. We want a (global) stack!
|
51
67
|
class Stack
|
@@ -55,7 +71,7 @@ module Trailblazer
|
|
55
71
|
end
|
56
72
|
|
57
73
|
def indent!
|
58
|
-
current << indented =
|
74
|
+
current << indented = Task.new
|
59
75
|
@stack << indented
|
60
76
|
end
|
61
77
|
|
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Nick Sutterer"]
|
9
9
|
spec.email = ["apotonick@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
13
|
-
spec.homepage = "http://trailblazer.to
|
11
|
+
spec.summary = %q{Define and run any desired circuit of business logic.}
|
12
|
+
spec.description = %q{Define and run any desired circuit of business logic. Used in Trailblazer's Operation to implement the railway.}
|
13
|
+
spec.homepage = "http://trailblazer.to"
|
14
14
|
spec.licenses = ["MIT"]
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-activity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hirb
|
@@ -94,8 +94,8 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
98
|
-
|
97
|
+
description: Define and run any desired circuit of business logic. Used in Trailblazer's
|
98
|
+
Operation to implement the railway.
|
99
99
|
email:
|
100
100
|
- apotonick@gmail.com
|
101
101
|
executables: []
|
@@ -155,7 +155,7 @@ files:
|
|
155
155
|
- lib/trailblazer/activity/version.rb
|
156
156
|
- lib/trailblazer/circuit.rb
|
157
157
|
- trailblazer-activity.gemspec
|
158
|
-
homepage: http://trailblazer.to
|
158
|
+
homepage: http://trailblazer.to
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata: {}
|
@@ -178,5 +178,5 @@ rubyforge_project:
|
|
178
178
|
rubygems_version: 2.7.3
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
|
-
summary:
|
181
|
+
summary: Define and run any desired circuit of business logic.
|
182
182
|
test_files: []
|