simple_flow 0.1.0 → 0.2.0
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/CHANGELOG.md +25 -0
- data/lib/simple_flow/version.rb +1 -1
- data/lib/simple_flow.rb +0 -17
- metadata +2 -68
- data/.envrc +0 -1
- data/.github/workflows/deploy-github-pages.yml +0 -52
- data/.rubocop.yml +0 -57
- data/COMMITS.md +0 -196
- data/Rakefile +0 -15
- data/benchmarks/parallel_vs_sequential.rb +0 -98
- data/benchmarks/pipeline_overhead.rb +0 -130
- data/docs/api/middleware.md +0 -468
- data/docs/api/parallel-step.md +0 -363
- data/docs/api/pipeline.md +0 -382
- data/docs/api/result.md +0 -375
- data/docs/concurrent/best-practices.md +0 -687
- data/docs/concurrent/introduction.md +0 -246
- data/docs/concurrent/parallel-steps.md +0 -418
- data/docs/concurrent/performance.md +0 -481
- data/docs/core-concepts/flow-control.md +0 -452
- data/docs/core-concepts/middleware.md +0 -389
- data/docs/core-concepts/overview.md +0 -219
- data/docs/core-concepts/pipeline.md +0 -315
- data/docs/core-concepts/result.md +0 -168
- data/docs/core-concepts/steps.md +0 -391
- data/docs/development/benchmarking.md +0 -443
- data/docs/development/contributing.md +0 -380
- data/docs/development/dagwood-concepts.md +0 -435
- data/docs/development/testing.md +0 -514
- data/docs/getting-started/examples.md +0 -197
- data/docs/getting-started/installation.md +0 -62
- data/docs/getting-started/quick-start.md +0 -218
- data/docs/guides/choosing-concurrency-model.md +0 -441
- data/docs/guides/complex-workflows.md +0 -440
- data/docs/guides/data-fetching.md +0 -478
- data/docs/guides/error-handling.md +0 -635
- data/docs/guides/file-processing.md +0 -505
- data/docs/guides/validation-patterns.md +0 -496
- data/docs/index.md +0 -169
- data/examples/.gitignore +0 -3
- data/examples/01_basic_pipeline.rb +0 -112
- data/examples/02_error_handling.rb +0 -178
- data/examples/03_middleware.rb +0 -186
- data/examples/04_parallel_automatic.rb +0 -221
- data/examples/05_parallel_explicit.rb +0 -279
- data/examples/06_real_world_ecommerce.rb +0 -288
- data/examples/07_real_world_etl.rb +0 -277
- data/examples/08_graph_visualization.rb +0 -246
- data/examples/09_pipeline_visualization.rb +0 -266
- data/examples/10_concurrency_control.rb +0 -235
- data/examples/11_sequential_dependencies.rb +0 -243
- data/examples/12_none_constant.rb +0 -161
- data/examples/README.md +0 -374
- data/examples/regression_test/01_basic_pipeline.txt +0 -38
- data/examples/regression_test/02_error_handling.txt +0 -92
- data/examples/regression_test/03_middleware.txt +0 -61
- data/examples/regression_test/04_parallel_automatic.txt +0 -86
- data/examples/regression_test/05_parallel_explicit.txt +0 -80
- data/examples/regression_test/06_real_world_ecommerce.txt +0 -53
- data/examples/regression_test/07_real_world_etl.txt +0 -58
- data/examples/regression_test/08_graph_visualization.txt +0 -429
- data/examples/regression_test/09_pipeline_visualization.txt +0 -305
- data/examples/regression_test/10_concurrency_control.txt +0 -96
- data/examples/regression_test/11_sequential_dependencies.txt +0 -86
- data/examples/regression_test/12_none_constant.txt +0 -64
- data/examples/regression_test.rb +0 -105
- data/mkdocs.yml +0 -146
- data/pipeline_graph.dot +0 -51
- data/pipeline_graph.html +0 -60
- data/pipeline_graph.mmd +0 -19
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
# Complex Workflows Guide
|
|
2
|
-
|
|
3
|
-
This guide demonstrates how to build sophisticated, real-world workflows using SimpleFlow's advanced features.
|
|
4
|
-
|
|
5
|
-
## E-Commerce Order Processing
|
|
6
|
-
|
|
7
|
-
Complete order processing pipeline with validation, inventory, payment, and notifications:
|
|
8
|
-
|
|
9
|
-
```ruby
|
|
10
|
-
class OrderProcessor
|
|
11
|
-
def self.build
|
|
12
|
-
SimpleFlow::Pipeline.new do
|
|
13
|
-
# Step 1: Validate order
|
|
14
|
-
step :validate_order, ->(result) {
|
|
15
|
-
order = result.value
|
|
16
|
-
errors = []
|
|
17
|
-
|
|
18
|
-
errors << "Missing email" unless order[:customer][:email]
|
|
19
|
-
errors << "No items" if order[:items].empty?
|
|
20
|
-
errors << "Missing payment" unless order[:payment][:card_token]
|
|
21
|
-
|
|
22
|
-
if errors.any?
|
|
23
|
-
result.halt.with_error(:validation, errors.join(", "))
|
|
24
|
-
else
|
|
25
|
-
result.with_context(:validated_at, Time.now).continue(order)
|
|
26
|
-
end
|
|
27
|
-
}, depends_on: []
|
|
28
|
-
|
|
29
|
-
# Steps 2-3: Parallel checks
|
|
30
|
-
step :check_inventory, ->(result) {
|
|
31
|
-
order = result.value
|
|
32
|
-
inventory_results = order[:items].map do |item|
|
|
33
|
-
InventoryService.check_availability(item[:product_id])
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
if inventory_results.all? { |r| r[:available] }
|
|
37
|
-
result.with_context(:inventory_check, inventory_results).continue(order)
|
|
38
|
-
else
|
|
39
|
-
result.halt.with_error(:inventory, "Items out of stock")
|
|
40
|
-
end
|
|
41
|
-
}, depends_on: [:validate_order]
|
|
42
|
-
|
|
43
|
-
step :calculate_shipping, ->(result) {
|
|
44
|
-
order = result.value
|
|
45
|
-
shipping = ShippingService.calculate(
|
|
46
|
-
order[:shipping_address],
|
|
47
|
-
order[:items]
|
|
48
|
-
)
|
|
49
|
-
result.with_context(:shipping, shipping).continue(order)
|
|
50
|
-
}, depends_on: [:validate_order]
|
|
51
|
-
|
|
52
|
-
# Step 4: Calculate totals
|
|
53
|
-
step :calculate_totals, ->(result) {
|
|
54
|
-
order = result.value
|
|
55
|
-
shipping = result.context[:shipping]
|
|
56
|
-
|
|
57
|
-
subtotal = order[:items].sum { |item| item[:price] * item[:quantity] }
|
|
58
|
-
tax = subtotal * 0.08
|
|
59
|
-
total = subtotal + tax + shipping[:cost]
|
|
60
|
-
|
|
61
|
-
result
|
|
62
|
-
.with_context(:subtotal, subtotal)
|
|
63
|
-
.with_context(:tax, tax)
|
|
64
|
-
.with_context(:total, total)
|
|
65
|
-
.continue(order)
|
|
66
|
-
}, depends_on: [:check_inventory, :calculate_shipping]
|
|
67
|
-
|
|
68
|
-
# Step 5: Process payment
|
|
69
|
-
step :process_payment, ->(result) {
|
|
70
|
-
order = result.value
|
|
71
|
-
total = result.context[:total]
|
|
72
|
-
|
|
73
|
-
payment_result = PaymentService.process(
|
|
74
|
-
total,
|
|
75
|
-
order[:payment][:card_token]
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
if payment_result[:status] == :success
|
|
79
|
-
result.with_context(:payment, payment_result).continue(order)
|
|
80
|
-
else
|
|
81
|
-
result.halt.with_error(:payment, payment_result[:reason])
|
|
82
|
-
end
|
|
83
|
-
}, depends_on: [:calculate_totals]
|
|
84
|
-
|
|
85
|
-
# Step 6: Reserve inventory
|
|
86
|
-
step :reserve_inventory, ->(result) {
|
|
87
|
-
order = result.value
|
|
88
|
-
reservation = InventoryService.reserve(order[:items])
|
|
89
|
-
result.with_context(:reservation, reservation).continue(order)
|
|
90
|
-
}, depends_on: [:process_payment]
|
|
91
|
-
|
|
92
|
-
# Step 7: Create shipment
|
|
93
|
-
step :create_shipment, ->(result) {
|
|
94
|
-
order = result.value
|
|
95
|
-
shipment = ShippingService.create_shipment(
|
|
96
|
-
order[:order_id],
|
|
97
|
-
order[:shipping_address]
|
|
98
|
-
)
|
|
99
|
-
result.with_context(:shipment, shipment).continue(order)
|
|
100
|
-
}, depends_on: [:reserve_inventory]
|
|
101
|
-
|
|
102
|
-
# Steps 8-9: Parallel notifications
|
|
103
|
-
step :send_email, ->(result) {
|
|
104
|
-
order = result.value
|
|
105
|
-
NotificationService.send_email(
|
|
106
|
-
order[:customer][:email],
|
|
107
|
-
"Order Confirmed",
|
|
108
|
-
order_confirmation_body(order, result.context)
|
|
109
|
-
)
|
|
110
|
-
result.continue(order)
|
|
111
|
-
}, depends_on: [:create_shipment]
|
|
112
|
-
|
|
113
|
-
step :send_sms, ->(result) {
|
|
114
|
-
order = result.value
|
|
115
|
-
if order[:customer][:phone]
|
|
116
|
-
NotificationService.send_sms(
|
|
117
|
-
order[:customer][:phone],
|
|
118
|
-
"Order confirmed! Tracking: #{result.context[:shipment][:tracking]}"
|
|
119
|
-
)
|
|
120
|
-
end
|
|
121
|
-
result.continue(order)
|
|
122
|
-
}, depends_on: [:create_shipment]
|
|
123
|
-
|
|
124
|
-
# Step 10: Finalize
|
|
125
|
-
step :finalize_order, ->(result) {
|
|
126
|
-
order = result.value
|
|
127
|
-
final_order = {
|
|
128
|
-
order_id: order[:order_id],
|
|
129
|
-
status: :confirmed,
|
|
130
|
-
total: result.context[:total],
|
|
131
|
-
payment_transaction: result.context[:payment][:transaction_id],
|
|
132
|
-
tracking_number: result.context[:shipment][:tracking_number]
|
|
133
|
-
}
|
|
134
|
-
result.continue(final_order)
|
|
135
|
-
}, depends_on: [:send_email, :send_sms]
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# Usage
|
|
141
|
-
result = OrderProcessor.build.call_parallel(
|
|
142
|
-
SimpleFlow::Result.new(order_data)
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
if result.continue?
|
|
146
|
-
puts "Order #{result.value[:order_id]} processed successfully"
|
|
147
|
-
else
|
|
148
|
-
puts "Order failed: #{result.errors}"
|
|
149
|
-
end
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## ETL Data Pipeline
|
|
153
|
-
|
|
154
|
-
Extract, Transform, Load pipeline with validation and error handling:
|
|
155
|
-
|
|
156
|
-
```ruby
|
|
157
|
-
class ETLPipeline
|
|
158
|
-
def self.build
|
|
159
|
-
SimpleFlow::Pipeline.new do
|
|
160
|
-
# Extract phase - parallel loading
|
|
161
|
-
step :extract_users, ->(result) {
|
|
162
|
-
users = DataSource.fetch_users_csv
|
|
163
|
-
result.with_context(:raw_users, users).continue(result.value)
|
|
164
|
-
}, depends_on: []
|
|
165
|
-
|
|
166
|
-
step :extract_orders, ->(result) {
|
|
167
|
-
orders = DataSource.fetch_orders_json
|
|
168
|
-
result.with_context(:raw_orders, orders).continue(result.value)
|
|
169
|
-
}, depends_on: []
|
|
170
|
-
|
|
171
|
-
step :extract_products, ->(result) {
|
|
172
|
-
products = DataSource.fetch_products_api
|
|
173
|
-
result.with_context(:raw_products, products).continue(result.value)
|
|
174
|
-
}, depends_on: []
|
|
175
|
-
|
|
176
|
-
# Transform phase - parallel transformations
|
|
177
|
-
step :transform_users, ->(result) {
|
|
178
|
-
users = result.context[:raw_users].map do |user|
|
|
179
|
-
{
|
|
180
|
-
id: user[:id],
|
|
181
|
-
name: user[:name].downcase.split.map(&:capitalize).join(' '),
|
|
182
|
-
email: user[:email].downcase,
|
|
183
|
-
signup_year: user[:signup_date].split('-').first.to_i
|
|
184
|
-
}
|
|
185
|
-
end
|
|
186
|
-
result.with_context(:users, users).continue(result.value)
|
|
187
|
-
}, depends_on: [:extract_users]
|
|
188
|
-
|
|
189
|
-
step :transform_orders, ->(result) {
|
|
190
|
-
orders = result.context[:raw_orders]
|
|
191
|
-
.reject { |o| o[:status] == "cancelled" }
|
|
192
|
-
.map do |order|
|
|
193
|
-
{
|
|
194
|
-
id: order[:order_id],
|
|
195
|
-
user_id: order[:user_id],
|
|
196
|
-
amount: order[:amount],
|
|
197
|
-
tax: (order[:amount] * 0.08).round(2),
|
|
198
|
-
total: (order[:amount] * 1.08).round(2)
|
|
199
|
-
}
|
|
200
|
-
end
|
|
201
|
-
result.with_context(:orders, orders).continue(result.value)
|
|
202
|
-
}, depends_on: [:extract_orders]
|
|
203
|
-
|
|
204
|
-
step :transform_products, ->(result) {
|
|
205
|
-
products = result.context[:raw_products].map do |product|
|
|
206
|
-
{
|
|
207
|
-
id: product[:product_id],
|
|
208
|
-
name: product[:name],
|
|
209
|
-
category: product[:category].to_sym
|
|
210
|
-
}
|
|
211
|
-
end
|
|
212
|
-
result.with_context(:products, products).continue(result.value)
|
|
213
|
-
}, depends_on: [:extract_products]
|
|
214
|
-
|
|
215
|
-
# Aggregate phase
|
|
216
|
-
step :aggregate_stats, ->(result) {
|
|
217
|
-
users = result.context[:users]
|
|
218
|
-
orders = result.context[:orders]
|
|
219
|
-
|
|
220
|
-
stats = users.map do |user|
|
|
221
|
-
user_orders = orders.select { |o| o[:user_id] == user[:id] }
|
|
222
|
-
{
|
|
223
|
-
user_id: user[:id],
|
|
224
|
-
name: user[:name],
|
|
225
|
-
total_orders: user_orders.size,
|
|
226
|
-
total_spent: user_orders.sum { |o| o[:total] },
|
|
227
|
-
avg_order: user_orders.empty? ? 0 : user_orders.sum { |o| o[:total] } / user_orders.size
|
|
228
|
-
}
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
result.with_context(:user_stats, stats).continue(result.value)
|
|
232
|
-
}, depends_on: [:transform_users, :transform_orders]
|
|
233
|
-
|
|
234
|
-
# Validation phase
|
|
235
|
-
step :validate_data, ->(result) {
|
|
236
|
-
users = result.context[:users]
|
|
237
|
-
orders = result.context[:orders]
|
|
238
|
-
|
|
239
|
-
issues = []
|
|
240
|
-
|
|
241
|
-
# Check for orphaned orders
|
|
242
|
-
user_ids = users.map { |u| u[:id] }
|
|
243
|
-
orphaned = orders.reject { |o| user_ids.include?(o[:user_id]) }
|
|
244
|
-
issues << "#{orphaned.size} orphaned orders" if orphaned.any?
|
|
245
|
-
|
|
246
|
-
result.with_context(:validation_warnings, issues).continue(result.value)
|
|
247
|
-
}, depends_on: [:aggregate_stats]
|
|
248
|
-
|
|
249
|
-
# Load phase
|
|
250
|
-
step :prepare_output, ->(result) {
|
|
251
|
-
output = {
|
|
252
|
-
metadata: {
|
|
253
|
-
processed_at: Time.now,
|
|
254
|
-
warnings: result.context[:validation_warnings]
|
|
255
|
-
},
|
|
256
|
-
analytics: {
|
|
257
|
-
user_stats: result.context[:user_stats],
|
|
258
|
-
summary: {
|
|
259
|
-
total_users: result.context[:users].size,
|
|
260
|
-
total_orders: result.context[:orders].size,
|
|
261
|
-
total_revenue: result.context[:orders].sum { |o| o[:total] }
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
result.continue(output)
|
|
266
|
-
}, depends_on: [:validate_data]
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## Multi-Service Integration
|
|
273
|
-
|
|
274
|
-
Orchestrating multiple external services:
|
|
275
|
-
|
|
276
|
-
```ruby
|
|
277
|
-
class UserOnboarding
|
|
278
|
-
def self.build
|
|
279
|
-
SimpleFlow::Pipeline.new do
|
|
280
|
-
# Validate user data
|
|
281
|
-
step :validate_user, ->(result) {
|
|
282
|
-
user_data = result.value
|
|
283
|
-
validator = UserValidator.new(user_data)
|
|
284
|
-
|
|
285
|
-
if validator.valid?
|
|
286
|
-
result.continue(user_data)
|
|
287
|
-
else
|
|
288
|
-
result.halt.with_error(:validation, validator.errors.join(", "))
|
|
289
|
-
end
|
|
290
|
-
}, depends_on: []
|
|
291
|
-
|
|
292
|
-
# Parallel service calls
|
|
293
|
-
step :create_auth_account, ->(result) {
|
|
294
|
-
user = result.value
|
|
295
|
-
auth_account = AuthService.create_account(
|
|
296
|
-
email: user[:email],
|
|
297
|
-
password: user[:password]
|
|
298
|
-
)
|
|
299
|
-
result.with_context(:auth_id, auth_account[:id]).continue(user)
|
|
300
|
-
}, depends_on: [:validate_user]
|
|
301
|
-
|
|
302
|
-
step :create_profile, ->(result) {
|
|
303
|
-
user = result.value
|
|
304
|
-
profile = ProfileService.create(
|
|
305
|
-
name: user[:name],
|
|
306
|
-
bio: user[:bio]
|
|
307
|
-
)
|
|
308
|
-
result.with_context(:profile_id, profile[:id]).continue(user)
|
|
309
|
-
}, depends_on: [:validate_user]
|
|
310
|
-
|
|
311
|
-
step :setup_preferences, ->(result) {
|
|
312
|
-
user = result.value
|
|
313
|
-
prefs = PreferenceService.initialize_defaults(user[:preferences] || {})
|
|
314
|
-
result.with_context(:preferences_id, prefs[:id]).continue(user)
|
|
315
|
-
}, depends_on: [:validate_user]
|
|
316
|
-
|
|
317
|
-
# Link accounts
|
|
318
|
-
step :link_accounts, ->(result) {
|
|
319
|
-
user_record = User.create!(
|
|
320
|
-
email: result.value[:email],
|
|
321
|
-
auth_id: result.context[:auth_id],
|
|
322
|
-
profile_id: result.context[:profile_id],
|
|
323
|
-
preferences_id: result.context[:preferences_id]
|
|
324
|
-
)
|
|
325
|
-
result.with_context(:user, user_record).continue(user_record)
|
|
326
|
-
}, depends_on: [:create_auth_account, :create_profile, :setup_preferences]
|
|
327
|
-
|
|
328
|
-
# Parallel post-creation tasks
|
|
329
|
-
step :send_welcome_email, ->(result) {
|
|
330
|
-
user = result.context[:user]
|
|
331
|
-
EmailService.send_welcome(user.email)
|
|
332
|
-
result.continue(result.value)
|
|
333
|
-
}, depends_on: [:link_accounts]
|
|
334
|
-
|
|
335
|
-
step :trigger_analytics, ->(result) {
|
|
336
|
-
user = result.context[:user]
|
|
337
|
-
AnalyticsService.track_signup(user)
|
|
338
|
-
result.continue(result.value)
|
|
339
|
-
}, depends_on: [:link_accounts]
|
|
340
|
-
|
|
341
|
-
step :create_trial_subscription, ->(result) {
|
|
342
|
-
user = result.context[:user]
|
|
343
|
-
subscription = BillingService.create_trial(user)
|
|
344
|
-
result.with_context(:subscription, subscription).continue(result.value)
|
|
345
|
-
}, depends_on: [:link_accounts]
|
|
346
|
-
|
|
347
|
-
# Finalize
|
|
348
|
-
step :finalize, ->(result) {
|
|
349
|
-
{
|
|
350
|
-
user_id: result.context[:user].id,
|
|
351
|
-
subscription_id: result.context[:subscription][:id],
|
|
352
|
-
onboarded_at: Time.now
|
|
353
|
-
}
|
|
354
|
-
}, depends_on: [:send_welcome_email, :trigger_analytics, :create_trial_subscription]
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
## Error Recovery Workflow
|
|
361
|
-
|
|
362
|
-
Advanced error handling with fallbacks and retries:
|
|
363
|
-
|
|
364
|
-
```ruby
|
|
365
|
-
class ResilientDataFetcher
|
|
366
|
-
def self.build
|
|
367
|
-
SimpleFlow::Pipeline.new do
|
|
368
|
-
# Try primary data source
|
|
369
|
-
step :fetch_primary, ->(result) {
|
|
370
|
-
begin
|
|
371
|
-
data = PrimaryAPI.fetch(result.value)
|
|
372
|
-
result.with_context(:source, :primary).continue(data)
|
|
373
|
-
rescue PrimaryAPI::Error => e
|
|
374
|
-
result
|
|
375
|
-
.with_context(:primary_error, e.message)
|
|
376
|
-
.continue(result.value)
|
|
377
|
-
end
|
|
378
|
-
}, depends_on: []
|
|
379
|
-
|
|
380
|
-
# Try secondary if primary failed
|
|
381
|
-
step :fetch_secondary, ->(result) {
|
|
382
|
-
# Skip if primary succeeded
|
|
383
|
-
if result.context[:source] == :primary
|
|
384
|
-
return result.continue(result.value)
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
begin
|
|
388
|
-
data = SecondaryAPI.fetch(result.value)
|
|
389
|
-
result.with_context(:source, :secondary).continue(data)
|
|
390
|
-
rescue SecondaryAPI::Error => e
|
|
391
|
-
result
|
|
392
|
-
.with_context(:secondary_error, e.message)
|
|
393
|
-
.continue(result.value)
|
|
394
|
-
end
|
|
395
|
-
}, depends_on: [:fetch_primary]
|
|
396
|
-
|
|
397
|
-
# Fallback to cache
|
|
398
|
-
step :fetch_cache, ->(result) {
|
|
399
|
-
# Skip if we have data
|
|
400
|
-
if result.context[:source]
|
|
401
|
-
return result.continue(result.value)
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
cached = CacheService.get(result.value)
|
|
405
|
-
if cached
|
|
406
|
-
result.with_context(:source, :cache).continue(cached)
|
|
407
|
-
else
|
|
408
|
-
result.halt.with_error(
|
|
409
|
-
:data_unavailable,
|
|
410
|
-
"All data sources failed: #{[
|
|
411
|
-
result.context[:primary_error],
|
|
412
|
-
result.context[:secondary_error]
|
|
413
|
-
].compact.join(', ')}"
|
|
414
|
-
)
|
|
415
|
-
end
|
|
416
|
-
}, depends_on: [:fetch_secondary]
|
|
417
|
-
|
|
418
|
-
# Update cache if we fetched from API
|
|
419
|
-
step :update_cache, ->(result) {
|
|
420
|
-
if [:primary, :secondary].include?(result.context[:source])
|
|
421
|
-
CacheService.set(result.value, result.value)
|
|
422
|
-
end
|
|
423
|
-
result.continue(result.value)
|
|
424
|
-
}, depends_on: [:fetch_cache]
|
|
425
|
-
end
|
|
426
|
-
end
|
|
427
|
-
end
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
## For complete examples, see:
|
|
431
|
-
|
|
432
|
-
- `/Users/dewayne/sandbox/git_repos/madbomber/simple_flow/examples/06_real_world_ecommerce.rb` - Full e-commerce workflow
|
|
433
|
-
- `/Users/dewayne/sandbox/git_repos/madbomber/simple_flow/examples/07_real_world_etl.rb` - Complete ETL pipeline
|
|
434
|
-
|
|
435
|
-
## Related Documentation
|
|
436
|
-
|
|
437
|
-
- [Error Handling](error-handling.md) - Error handling strategies
|
|
438
|
-
- [Validation Patterns](validation-patterns.md) - Data validation
|
|
439
|
-
- [Data Fetching](data-fetching.md) - Fetching external data
|
|
440
|
-
- [Parallel Steps](../concurrent/parallel-steps.md) - Concurrent execution
|