decouplio 1.0.0alpha2 → 1.0.0alpha5
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/.circleci/config.yml +11 -1
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -1
- data/README.md +2 -17
- data/benchmarks/multi_step_benchmark.rb +11 -10
- data/benchmarks/single_step_benchmark.rb +1 -1
- data/decouplio.gemspec +4 -4
- data/lib/decouplio/action.rb +12 -0
- data/lib/decouplio/composer.rb +47 -24
- data/lib/decouplio/const/doby_aide_options.rb +16 -0
- data/lib/decouplio/const/error_messages.rb +9 -0
- data/lib/decouplio/const/types.rb +14 -6
- data/lib/decouplio/const/validations/aide.rb +38 -0
- data/lib/decouplio/const/validations/doby.rb +36 -0
- data/lib/decouplio/const/validations/fail.rb +4 -0
- data/lib/decouplio/const/validations/octo.rb +2 -1
- data/lib/decouplio/errors/{deny_can_not_be_first_step_error.rb → aide_can_not_be_first_step_error.rb} +3 -3
- data/lib/decouplio/errors/aide_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/aide_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/doby_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/doby_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/execution_error.rb +20 -0
- data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
- data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
- data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
- data/lib/decouplio/logic_dsl.rb +23 -8
- data/lib/decouplio/options_validator.rb +157 -13
- data/lib/decouplio/steps/aide.rb +37 -0
- data/lib/decouplio/steps/base_resq.rb +13 -3
- data/lib/decouplio/steps/doby.rb +9 -8
- data/lib/decouplio/steps/octo.rb +7 -2
- data/lib/decouplio/validators/condition.rb +10 -0
- data/lib/decouplio/version.rb +1 -1
- metadata +24 -42
- data/docs/_config.yml +0 -1
- data/docs/benchmarks.md +0 -1
- data/docs/context.md +0 -74
- data/docs/context.rb +0 -62
- data/docs/deny.rb +0 -59
- data/docs/doby.rb +0 -38
- data/docs/doby_deny.md +0 -171
- data/docs/error_store.md +0 -347
- data/docs/error_store.rb +0 -202
- data/docs/fail.md +0 -1159
- data/docs/fail.rb +0 -859
- data/docs/index.md +0 -25
- data/docs/inner_action.md +0 -63
- data/docs/inner_action.rb +0 -43
- data/docs/logic_block.md +0 -25
- data/docs/octo.md +0 -269
- data/docs/octo.rb +0 -164
- data/docs/pass.md +0 -309
- data/docs/pass.rb +0 -213
- data/docs/quick_start.md +0 -71
- data/docs/quick_start.rb +0 -38
- data/docs/resq.md +0 -263
- data/docs/resq.rb +0 -176
- data/docs/step.md +0 -885
- data/docs/step.rb +0 -627
- data/docs/step_as_a_service.md +0 -123
- data/docs/step_as_a_service.rb +0 -77
- data/docs/wrap.md +0 -240
- data/docs/wrap.rb +0 -137
- data/lib/decouplio/const/validations/deny.rb +0 -11
- data/lib/decouplio/steps/deny.rb +0 -31
data/docs/resq.md
DELETED
@@ -1,263 +0,0 @@
|
|
1
|
-
# Resq
|
2
|
-
|
3
|
-
Step type which can be use to handle errors raised during step invocation.
|
4
|
-
|
5
|
-
## Signature
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
resq(**options)
|
9
|
-
```
|
10
|
-
|
11
|
-
## Allowed for steps
|
12
|
-
|
13
|
-
<style>
|
14
|
-
.allowed-steps {
|
15
|
-
width: 70%;
|
16
|
-
text-align: center;
|
17
|
-
}
|
18
|
-
.allowed-steps th {
|
19
|
-
background: grey;
|
20
|
-
word-wrap: break-word;
|
21
|
-
text-align: center;
|
22
|
-
}
|
23
|
-
.allowed-steps tr:nth-child(1) td:nth-child(2) { background: green; }
|
24
|
-
.allowed-steps tr:nth-child(2) td:nth-child(2) { background: green; }
|
25
|
-
.allowed-steps tr:nth-child(3) td:nth-child(2) { background: green; }
|
26
|
-
.allowed-steps tr:nth-child(4) td:nth-child(2) { background: green; }
|
27
|
-
.allowed-steps tr:nth-child(5) td:nth-child(2) { background: red; }
|
28
|
-
</style>
|
29
|
-
|
30
|
-
<div class="allowed-steps">
|
31
|
-
|
32
|
-
|Step type|Allowed|
|
33
|
-
|-|-|
|
34
|
-
|step|Yes|
|
35
|
-
|fail|Yes|
|
36
|
-
|pass|Yes|
|
37
|
-
|wrap|Yes|
|
38
|
-
|octo|NO|
|
39
|
-
|
40
|
-
</div>
|
41
|
-
|
42
|
-
## Behavior
|
43
|
-
|
44
|
-
When `resq` step is defined after allowed step then it will catch error with class specified in options and call handler method. `resq` applies only for step which is defined above.
|
45
|
-
|
46
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
47
|
-
<p>
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
require 'decouplio'
|
51
|
-
|
52
|
-
class SomeAction < Decouplio::Action
|
53
|
-
logic do
|
54
|
-
step :step_one
|
55
|
-
resq handler_method: ArgumentError
|
56
|
-
step :step_two
|
57
|
-
fail :fail_one
|
58
|
-
end
|
59
|
-
|
60
|
-
def step_one(lambda_for_step_one:, **)
|
61
|
-
ctx[:step_one] = lambda_for_step_one.call
|
62
|
-
end
|
63
|
-
|
64
|
-
def step_two(**)
|
65
|
-
ctx[:step_two] = 'Success'
|
66
|
-
end
|
67
|
-
|
68
|
-
def fail_one(**)
|
69
|
-
ctx[:fail_one] = 'Failure'
|
70
|
-
end
|
71
|
-
|
72
|
-
def handler_method(error, **this_is_ctx)
|
73
|
-
ctx[:error] = error.message
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
success_action = SomeAction.call(lambda_for_step_one: -> { true })
|
78
|
-
failure_action = SomeAction.call(lambda_for_step_one: -> { false })
|
79
|
-
errored_action = SomeAction.call(
|
80
|
-
lambda_for_step_one: -> { raise ArgumentError, 'some error message' }
|
81
|
-
)
|
82
|
-
|
83
|
-
success_action # =>
|
84
|
-
# Result: success
|
85
|
-
|
86
|
-
# Railway Flow:
|
87
|
-
# step_one -> step_two
|
88
|
-
|
89
|
-
# Context:
|
90
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a05628 resq.rb:32 (lambda)>, :step_one=>true, :step_two=>"Success"}
|
91
|
-
|
92
|
-
# Errors:
|
93
|
-
# {}
|
94
|
-
failure_action # =>
|
95
|
-
# Result: failure
|
96
|
-
|
97
|
-
# Railway Flow:
|
98
|
-
# step_one -> fail_one
|
99
|
-
|
100
|
-
# Context:
|
101
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a04f48 resq.rb:33 (lambda)>, :step_one=>false, :fail_one=>"Failure"}
|
102
|
-
|
103
|
-
# Errors:
|
104
|
-
# {}
|
105
|
-
errored_action # =>
|
106
|
-
# Result: failure
|
107
|
-
|
108
|
-
# Railway Flow:
|
109
|
-
# step_one -> handler_method -> fail_one
|
110
|
-
|
111
|
-
# Context:
|
112
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a04b60 resq.rb:35 (lambda)>, :error=>"some error message", :fail_one=>"Failure"}
|
113
|
-
|
114
|
-
# Errors:
|
115
|
-
# {}
|
116
|
-
```
|
117
|
-
|
118
|
-
```mermaid
|
119
|
-
flowchart LR
|
120
|
-
1(start)-->2(step_one);
|
121
|
-
2(step_one)-->|success track|3(step_two);
|
122
|
-
3(step_two)-->|success track|4(finish success);
|
123
|
-
2(step_one)-->|failure track|5(fail_one);
|
124
|
-
5(fail_one)-->|failure track|6(finish failure);
|
125
|
-
2(step_one)-->|error track|7(handler_method);
|
126
|
-
7(handler_method)-->|error track|5(fail_one);
|
127
|
-
```
|
128
|
-
|
129
|
-
</p>
|
130
|
-
</details>
|
131
|
-
|
132
|
-
***
|
133
|
-
|
134
|
-
## When several error handlers and error classes
|
135
|
-
|
136
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
137
|
-
<p>
|
138
|
-
|
139
|
-
```ruby
|
140
|
-
require 'decouplio'
|
141
|
-
|
142
|
-
class SomeActionSeveralHandlersErrorClasses < Decouplio::Action
|
143
|
-
logic do
|
144
|
-
step :step_one
|
145
|
-
resq handler_method_one: [ArgumentError, NoMethodError],
|
146
|
-
handler_method_two: NotImplementedError
|
147
|
-
step :step_two
|
148
|
-
fail :fail_one
|
149
|
-
end
|
150
|
-
|
151
|
-
def step_one(lambda_for_step_one:, **)
|
152
|
-
ctx[:step_one] = lambda_for_step_one.call
|
153
|
-
end
|
154
|
-
|
155
|
-
def step_two(**)
|
156
|
-
ctx[:step_two] = 'Success'
|
157
|
-
end
|
158
|
-
|
159
|
-
def fail_one(**)
|
160
|
-
ctx[:fail_one] = 'Failure'
|
161
|
-
end
|
162
|
-
|
163
|
-
def handler_method_one(error, **this_is_ctx)
|
164
|
-
ctx[:error] = error.message
|
165
|
-
end
|
166
|
-
|
167
|
-
def handler_method_two(error, **this_is_ctx)
|
168
|
-
ctx[:error] = error.message
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
success_action = SomeActionSeveralHandlersErrorClasses.call(
|
173
|
-
lambda_for_step_one: -> { true }
|
174
|
-
)
|
175
|
-
failure_action = SomeActionSeveralHandlersErrorClasses.call(
|
176
|
-
lambda_for_step_one: -> { false }
|
177
|
-
)
|
178
|
-
argument_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
179
|
-
lambda_for_step_one: -> { raise ArgumentError, 'Argument error message' }
|
180
|
-
)
|
181
|
-
no_method_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
182
|
-
lambda_for_step_one: -> { raise NoMethodError, 'NoMethodError error message' }
|
183
|
-
)
|
184
|
-
no_implemented_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
185
|
-
lambda_for_step_one: -> { raise NotImplementedError, 'NotImplementedError error message' }
|
186
|
-
)
|
187
|
-
|
188
|
-
success_action # =>
|
189
|
-
# Result: success
|
190
|
-
|
191
|
-
# Railway Flow:
|
192
|
-
# step_one -> step_two
|
193
|
-
|
194
|
-
# Context:
|
195
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f638 resq.rb:106 (lambda)>, :step_one=>true, :step_two=>"Success"}
|
196
|
-
|
197
|
-
# Errors:
|
198
|
-
# {}
|
199
|
-
|
200
|
-
failure_action # =>
|
201
|
-
# Result: failure
|
202
|
-
|
203
|
-
# Railway Flow:
|
204
|
-
# step_one -> fail_one
|
205
|
-
|
206
|
-
# Context:
|
207
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f390 resq.rb:109 (lambda)>, :step_one=>false, :fail_one=>"Failure"}
|
208
|
-
|
209
|
-
# Errors:
|
210
|
-
# {}
|
211
|
-
argument_error_action # =>
|
212
|
-
# Result: failure
|
213
|
-
|
214
|
-
# Railway Flow:
|
215
|
-
# step_one -> handler_method_one -> fail_one
|
216
|
-
|
217
|
-
# Context:
|
218
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f138 resq.rb:112 (lambda)>, :error=>"Argument error message", :fail_one=>"Failure"}
|
219
|
-
|
220
|
-
# Errors:
|
221
|
-
# {}
|
222
|
-
no_method_error_action # =>
|
223
|
-
# Result: failure
|
224
|
-
|
225
|
-
# Railway Flow:
|
226
|
-
# step_one -> handler_method_one -> fail_one
|
227
|
-
|
228
|
-
# Context:
|
229
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149edc8 resq.rb:115 (lambda)>, :error=>"NoMethodError error message", :fail_one=>"Failure"}
|
230
|
-
|
231
|
-
# Errors:
|
232
|
-
# {}
|
233
|
-
no_implemented_error_action # =>
|
234
|
-
# Result: failure
|
235
|
-
|
236
|
-
# Railway Flow:
|
237
|
-
# step_one -> handler_method_two -> fail_one
|
238
|
-
|
239
|
-
# Context:
|
240
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149e8c8 resq.rb:118 (lambda)>, :error=>"NotImplementedError error message", :fail_one=>"Failure"}
|
241
|
-
|
242
|
-
# Errors:
|
243
|
-
# {}
|
244
|
-
```
|
245
|
-
|
246
|
-
```mermaid
|
247
|
-
flowchart LR
|
248
|
-
1(start)-->2(step_one);
|
249
|
-
2(step_one)-->|success track|3(step_two);
|
250
|
-
3(step_two)-->|success track|4(finish success);
|
251
|
-
2(step_one)-->|failure track|5(fail_one);
|
252
|
-
5(fail_one)-->|failure track|6(finish failure);
|
253
|
-
2(step_one)-->|ArgumentError|7(handler_method_one);
|
254
|
-
2(step_one)-->|NoMethodError|7(handler_method_one);
|
255
|
-
2(step_one)-->|NotImplementedError|8(handler_method_two);
|
256
|
-
7(handler_method_one)-->|error track|5(fail_one);
|
257
|
-
8(handler_method_two)-->|error track|5(fail_one);
|
258
|
-
```
|
259
|
-
|
260
|
-
</p>
|
261
|
-
</details>
|
262
|
-
|
263
|
-
***
|
data/docs/resq.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
require_relative '../lib/decouplio'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# Behavior
|
6
|
-
|
7
|
-
class SomeAction < Decouplio::Action
|
8
|
-
logic do
|
9
|
-
step :step_one
|
10
|
-
resq handler_method: ArgumentError
|
11
|
-
step :step_two
|
12
|
-
fail :fail_one
|
13
|
-
end
|
14
|
-
|
15
|
-
def step_one(lambda_for_step_one:, **)
|
16
|
-
ctx[:step_one] = lambda_for_step_one.call
|
17
|
-
end
|
18
|
-
|
19
|
-
def step_two(**)
|
20
|
-
ctx[:step_two] = 'Success'
|
21
|
-
end
|
22
|
-
|
23
|
-
def fail_one(**)
|
24
|
-
ctx[:fail_one] = 'Failure'
|
25
|
-
end
|
26
|
-
|
27
|
-
def handler_method(error, **this_is_ctx)
|
28
|
-
ctx[:error] = error.message
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
success_action = SomeAction.call(lambda_for_step_one: -> { true })
|
33
|
-
failure_action = SomeAction.call(lambda_for_step_one: -> { false })
|
34
|
-
errored_action = SomeAction.call(
|
35
|
-
lambda_for_step_one: -> { raise ArgumentError, 'some error message' }
|
36
|
-
)
|
37
|
-
|
38
|
-
puts success_action # =>
|
39
|
-
# Result: success
|
40
|
-
|
41
|
-
# Railway Flow:
|
42
|
-
# step_one -> step_two
|
43
|
-
|
44
|
-
# Context:
|
45
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a05628 resq.rb:32 (lambda)>, :step_one=>true, :step_two=>"Success"}
|
46
|
-
|
47
|
-
# Errors:
|
48
|
-
# {}
|
49
|
-
puts failure_action # =>
|
50
|
-
# Result: failure
|
51
|
-
|
52
|
-
# Railway Flow:
|
53
|
-
# step_one -> fail_one
|
54
|
-
|
55
|
-
# Context:
|
56
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a04f48 resq.rb:33 (lambda)>, :step_one=>false, :fail_one=>"Failure"}
|
57
|
-
|
58
|
-
# Errors:
|
59
|
-
# {}
|
60
|
-
puts errored_action # =>
|
61
|
-
# Result: failure
|
62
|
-
|
63
|
-
# Railway Flow:
|
64
|
-
# step_one -> handler_method -> fail_one
|
65
|
-
|
66
|
-
# Context:
|
67
|
-
# {:lambda_for_step_one=>#<Proc:0x0000561525a04b60 resq.rb:35 (lambda)>, :error=>"some error message", :fail_one=>"Failure"}
|
68
|
-
|
69
|
-
# Errors:
|
70
|
-
# {}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# When several error handlers and error classes
|
75
|
-
class SomeActionSeveralHandlersErrorClasses < Decouplio::Action
|
76
|
-
logic do
|
77
|
-
step :step_one
|
78
|
-
resq handler_method_one: [ArgumentError, NoMethodError],
|
79
|
-
handler_method_two: NotImplementedError
|
80
|
-
step :step_two
|
81
|
-
fail :fail_one
|
82
|
-
end
|
83
|
-
|
84
|
-
def step_one(lambda_for_step_one:, **)
|
85
|
-
ctx[:step_one] = lambda_for_step_one.call
|
86
|
-
end
|
87
|
-
|
88
|
-
def step_two(**)
|
89
|
-
ctx[:step_two] = 'Success'
|
90
|
-
end
|
91
|
-
|
92
|
-
def fail_one(**)
|
93
|
-
ctx[:fail_one] = 'Failure'
|
94
|
-
end
|
95
|
-
|
96
|
-
def handler_method_one(error, **this_is_ctx)
|
97
|
-
ctx[:error] = error.message
|
98
|
-
end
|
99
|
-
|
100
|
-
def handler_method_two(error, **this_is_ctx)
|
101
|
-
ctx[:error] = error.message
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
success_action = SomeActionSeveralHandlersErrorClasses.call(
|
106
|
-
lambda_for_step_one: -> { true }
|
107
|
-
)
|
108
|
-
failure_action = SomeActionSeveralHandlersErrorClasses.call(
|
109
|
-
lambda_for_step_one: -> { false }
|
110
|
-
)
|
111
|
-
argument_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
112
|
-
lambda_for_step_one: -> { raise ArgumentError, 'Argument error message' }
|
113
|
-
)
|
114
|
-
no_method_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
115
|
-
lambda_for_step_one: -> { raise NoMethodError, 'NoMethodError error message' }
|
116
|
-
)
|
117
|
-
no_implemented_error_action = SomeActionSeveralHandlersErrorClasses.call(
|
118
|
-
lambda_for_step_one: -> { raise NotImplementedError, 'NotImplementedError error message' }
|
119
|
-
)
|
120
|
-
|
121
|
-
puts success_action # =>
|
122
|
-
# Result: success
|
123
|
-
|
124
|
-
# Railway Flow:
|
125
|
-
# step_one -> step_two
|
126
|
-
|
127
|
-
# Context:
|
128
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f638 resq.rb:106 (lambda)>, :step_one=>true, :step_two=>"Success"}
|
129
|
-
|
130
|
-
# Errors:
|
131
|
-
# {}
|
132
|
-
|
133
|
-
puts failure_action # =>
|
134
|
-
# Result: failure
|
135
|
-
|
136
|
-
# Railway Flow:
|
137
|
-
# step_one -> fail_one
|
138
|
-
|
139
|
-
# Context:
|
140
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f390 resq.rb:109 (lambda)>, :step_one=>false, :fail_one=>"Failure"}
|
141
|
-
|
142
|
-
# Errors:
|
143
|
-
# {}
|
144
|
-
puts argument_error_action # =>
|
145
|
-
# Result: failure
|
146
|
-
|
147
|
-
# Railway Flow:
|
148
|
-
# step_one -> handler_method_one -> fail_one
|
149
|
-
|
150
|
-
# Context:
|
151
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149f138 resq.rb:112 (lambda)>, :error=>"Argument error message", :fail_one=>"Failure"}
|
152
|
-
|
153
|
-
# Errors:
|
154
|
-
# {}
|
155
|
-
puts no_method_error_action # =>
|
156
|
-
# Result: failure
|
157
|
-
|
158
|
-
# Railway Flow:
|
159
|
-
# step_one -> handler_method_one -> fail_one
|
160
|
-
|
161
|
-
# Context:
|
162
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149edc8 resq.rb:115 (lambda)>, :error=>"NoMethodError error message", :fail_one=>"Failure"}
|
163
|
-
|
164
|
-
# Errors:
|
165
|
-
# {}
|
166
|
-
puts no_implemented_error_action # =>
|
167
|
-
# Result: failure
|
168
|
-
|
169
|
-
# Railway Flow:
|
170
|
-
# step_one -> handler_method_two -> fail_one
|
171
|
-
|
172
|
-
# Context:
|
173
|
-
# {:lambda_for_step_one=>#<Proc:0x0000557a7149e8c8 resq.rb:118 (lambda)>, :error=>"NotImplementedError error message", :fail_one=>"Failure"}
|
174
|
-
|
175
|
-
# Errors:
|
176
|
-
# {}
|