trailblazer-activity 0.10.0 → 0.10.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 +4 -4
- data/CHANGES.md +4 -0
- data/README.md +19 -14
- data/lib/trailblazer/activity/circuit.rb +29 -1
- data/lib/trailblazer/activity/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c94f3dbe368043f005ec5d68fc099246c8f302dd6e1b366989b321665d5f2b98
|
|
4
|
+
data.tar.gz: 28f0b58b9d2de3b7adffd543860baed3e47eb25945161cbe7cc5f45a8f907abd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78eaabeff700dd6b22ff61efe8efe993287875c02e7a80197ca6880c435bba2732d61ebaa41acc4da3737ad556ae669b8dc03f6dad445394486e7a1298d62569
|
|
7
|
+
data.tar.gz: '08b7cbeea9a42fc99a8d38f95439d6e265f0fe4051ccfa8e95a18f18c117e34bf6ae2824e07a8eb139db32e4559bd094c30d621e1fb82cc2c8e80916e7c6ee88'
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# Activity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Implements Intermediate, Implementation and compiler
|
|
4
4
|
|
|
5
5
|
The `activity` gem brings a light-weight DSL to define business processes, and the runtime logic to run those activities.
|
|
6
6
|
|
|
7
7
|
A process is a set of arbitrary pieces of logic you define, chained together and put into a meaningful context by an activity. Activity lets you focus on the implementation of steps while Trailblazer takes care of the control flow.
|
|
8
8
|
|
|
9
|
-
Please find the [full documentation on the Trailblazer website](
|
|
9
|
+
Please find the [full documentation on the Trailblazer website](https://2019.trailblazer.to/2.1/docs/activity.html). [Note that the docs are WIP.]
|
|
10
10
|
|
|
11
11
|
## Example
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
In conjunction with [`dsl-linear`](https://github.com/trailblazer/trailblazer-activity-dsl-linear), the `activity` gem provides three default patterns to model processes: `Path`, `Railway` and `FastTrack`. Here's an example of what a railway activity could look like, along with some more complex connections (you can read more about Railway strategy in the [docs](https://2019.trailblazer.to/2.1/docs/activity.html#activity-strategy-railway)).
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module_function
|
|
16
|
+
require "trailblazer-activity"
|
|
17
|
+
require "trailblazer-activity-dsl-linear"
|
|
19
18
|
|
|
19
|
+
class Memo::Update < Trailblazer::Activity::Railway
|
|
20
20
|
# here goes your business logic
|
|
21
21
|
#
|
|
22
22
|
def find_model(ctx, id:, **)
|
|
@@ -39,10 +39,10 @@ module Memo::Update
|
|
|
39
39
|
|
|
40
40
|
# here comes the DSL describing the layout of the activity
|
|
41
41
|
#
|
|
42
|
-
step
|
|
43
|
-
step
|
|
44
|
-
step
|
|
45
|
-
fail
|
|
42
|
+
step :find_model
|
|
43
|
+
step :validate, Output(:failure) => End(:validation_error)
|
|
44
|
+
step :save
|
|
45
|
+
fail :log_error
|
|
46
46
|
end
|
|
47
47
|
```
|
|
48
48
|
|
|
@@ -71,17 +71,22 @@ With Activity, modeling business processes turns out to be ridiculously simple:
|
|
|
71
71
|
## Features
|
|
72
72
|
|
|
73
73
|
* Activities can model any process with arbitrary flow and connections.
|
|
74
|
-
* Nesting and compositions are allowed and encouraged.
|
|
74
|
+
* Nesting and compositions are allowed and encouraged (via Trailblazer's [`dsl-linear`](https://github.com/trailblazer/trailblazer-activity-dsl-linear) gem).
|
|
75
75
|
* Different step interfaces, manual processing of DSL options, etc is all possible.
|
|
76
76
|
* Steps can be any kind of callable objects.
|
|
77
|
-
* Tracing!
|
|
77
|
+
* Tracing! (via Trailblazer's [`developer`](https://github.com/trailblazer/trailblazer-developer) gem)
|
|
78
78
|
|
|
79
79
|
## Operation
|
|
80
80
|
|
|
81
|
-
Trailblazer's [`Operation`](
|
|
81
|
+
Trailblazer's [`Operation`](https://2019.trailblazer.to/2.1/docs/operation.html#operation-overview) internally uses an activity to model the processes.
|
|
82
|
+
|
|
83
|
+
## Workflow
|
|
84
|
+
Activities can be formed into bigger compounds and using workflow, you can build long-running processes such as a moderated blog post or a parcel delivery. Also, you don't have to use the DSL but can use the [`editor`](https://2019.trailblazer.to/2.1/docs/pro.html#pro-editor)instead(cool for more complex, long-running flows). Here comes a sample screenshot.
|
|
85
|
+
|
|
86
|
+
<img src="http://2019.trailblazer.to/2.1/dist/img/flow.png">
|
|
82
87
|
|
|
83
88
|
## License
|
|
84
89
|
|
|
85
90
|
© Copyright 2018, Trailblazer GmbH
|
|
86
91
|
|
|
87
|
-
Licensed under the LGPLv3 license. We also offer a
|
|
92
|
+
Licensed under the LGPLv3 license. We also offer a commercial-friendly [license](https://2019.trailblazer.to/2.1/docs/pro.html#pro-license).
|
|
@@ -51,7 +51,16 @@ module Trailblazer
|
|
|
51
51
|
# Stop execution of the circuit when we hit a stop event (< End). This could be an task's End or Suspend.
|
|
52
52
|
return [ last_signal, args ] if @stop_events.include?(task) # DISCUSS: return circuit_options here?
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
if (next_task = next_for(task, last_signal))
|
|
55
|
+
task = next_task
|
|
56
|
+
else
|
|
57
|
+
raise IllegalSignalError.new(
|
|
58
|
+
task,
|
|
59
|
+
signal: last_signal,
|
|
60
|
+
outputs: @map[task],
|
|
61
|
+
exec_context: circuit_options[:exec_context], # passed at run-time from DSL
|
|
62
|
+
)
|
|
63
|
+
end
|
|
55
64
|
end
|
|
56
65
|
end
|
|
57
66
|
|
|
@@ -67,7 +76,26 @@ module Trailblazer
|
|
|
67
76
|
outputs[signal]
|
|
68
77
|
end
|
|
69
78
|
|
|
79
|
+
# Common reasons to raise IllegalSignalError are
|
|
80
|
+
# * Returning invalid signal from custom Macros
|
|
81
|
+
# * Returning invalid signal from steps which are not taskWrapped, for example: `step task: method(:validate)`
|
|
82
|
+
#
|
|
83
|
+
# Rest assured, it won't be raised in case of below scenarios where they can return any value,
|
|
84
|
+
# * Steps with instance method signature, for example, `step :load_user`
|
|
85
|
+
# * Steps with proc signature, for example `step ->(ctx, **){}`
|
|
70
86
|
class IllegalSignalError < RuntimeError
|
|
87
|
+
attr_reader :task, :signal
|
|
88
|
+
|
|
89
|
+
def initialize(task, signal:, outputs:, exec_context:)
|
|
90
|
+
@task = task
|
|
91
|
+
@signal = signal
|
|
92
|
+
|
|
93
|
+
message = "#{exec_context.class}: \n\t" \
|
|
94
|
+
"\sUnrecognized Signal `#{signal.inspect}` returned from #{task.inspect}. Registered signals are, \n" \
|
|
95
|
+
"- #{outputs.keys.join("\n- ")}"
|
|
96
|
+
|
|
97
|
+
super(message)
|
|
98
|
+
end
|
|
71
99
|
end
|
|
72
100
|
end
|
|
73
101
|
end
|
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.10.
|
|
4
|
+
version: 0.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: trailblazer-context
|
|
@@ -142,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
143
|
version: '0'
|
|
144
144
|
requirements: []
|
|
145
|
-
|
|
146
|
-
rubygems_version: 2.7.6
|
|
145
|
+
rubygems_version: 3.0.8
|
|
147
146
|
signing_key:
|
|
148
147
|
specification_version: 4
|
|
149
148
|
summary: Runtime code for Trailblazer activities.
|