ruby_reactor 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 +4 -4
- data/README.md +31 -4
- data/documentation/testing.md +812 -0
- data/lib/ruby_reactor/configuration.rb +1 -1
- data/lib/ruby_reactor/context.rb +13 -5
- data/lib/ruby_reactor/context_serializer.rb +55 -4
- data/lib/ruby_reactor/dsl/reactor.rb +3 -2
- data/lib/ruby_reactor/error/step_failure_error.rb +5 -2
- data/lib/ruby_reactor/executor/result_handler.rb +8 -2
- data/lib/ruby_reactor/executor/retry_manager.rb +15 -7
- data/lib/ruby_reactor/executor/step_executor.rb +24 -99
- data/lib/ruby_reactor/executor.rb +3 -13
- data/lib/ruby_reactor/map/collector.rb +16 -15
- data/lib/ruby_reactor/map/element_executor.rb +90 -104
- data/lib/ruby_reactor/map/execution.rb +2 -1
- data/lib/ruby_reactor/map/helpers.rb +2 -1
- data/lib/ruby_reactor/map/result_enumerator.rb +1 -1
- data/lib/ruby_reactor/reactor.rb +174 -16
- data/lib/ruby_reactor/rspec/helpers.rb +17 -0
- data/lib/ruby_reactor/rspec/matchers.rb +256 -0
- data/lib/ruby_reactor/rspec/step_executor_patch.rb +85 -0
- data/lib/ruby_reactor/rspec/test_subject.rb +625 -0
- data/lib/ruby_reactor/rspec.rb +18 -0
- data/lib/ruby_reactor/{async_router.rb → sidekiq_adapter.rb} +10 -5
- data/lib/ruby_reactor/sidekiq_workers/worker.rb +1 -3
- data/lib/ruby_reactor/step/compose_step.rb +0 -1
- data/lib/ruby_reactor/step/map_step.rb +11 -18
- data/lib/ruby_reactor/version.rb +1 -1
- data/lib/ruby_reactor/web/api.rb +32 -24
- data/lib/ruby_reactor.rb +70 -10
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3ddfd9b6e65d03e5c00d7980563da39b4132fc1d5f0dbe14e5b782d039c7f68
|
|
4
|
+
data.tar.gz: 785cc8ac8d426433a00f378eafb8f312b343950ecf496e2af0a6fe9e48115c29
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 549a49deff5d63e129c0b4c043cbc3987dbbb09b054907a5acb8941af85fedb5f9706bad8d56948bbc7ea889eba19174254962ca987e7835b4cd0a7bf3f9e165
|
|
7
|
+
data.tar.gz: 319399c2854cccb505fc7e8f6c964eeeb527bad375ed513b1a2c2ea89b77445283f287bbff5a0892902a56a5a56b5a9aff105a0164006abf407473ad3780a58d
|
data/README.md
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
# RubyReactor
|
|
7
7
|
|
|
8
|
+
A dynamic, dependency-resolving saga orchestrator for Ruby. Ruby Reactor implements the Saga pattern with compensation-based error handling and DAG-based execution planning. It leverages **Sidekiq** for asynchronous execution and **Redis** for state persistence.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
8
12
|
## Why Ruby Reactor?
|
|
9
13
|
|
|
10
14
|
Building complex business transactions often results in spaghetti code or brittle "god classes." Ruby Reactor solves this by implementing the **Saga Pattern** in a lightweight, developer-friendly package. It lets you define workflows as clear, dependency-driven steps without the boilerplate of heavy enterprise frameworks.
|
|
11
15
|
|
|
12
16
|
The key value is **Reliability**: if any part of your workflow fails, Ruby Reactor automatically triggers compensation logic to undo previous steps, ensuring your system never ends up in a corrupted half-state. Whether you're coordinating microservices or monolith modules, you get atomic-like consistency with background processing built-in.
|
|
13
17
|
|
|
14
|
-
A dynamic, dependency-resolving saga orchestrator for Ruby. Ruby Reactor implements the Saga pattern with compensation-based error handling and DAG-based execution planning. It leverages **Sidekiq** for asynchronous execution and **Redis** for state persistence.
|
|
15
|
-
|
|
16
|
-

|
|
17
|
-
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
20
|
- **DAG-based Execution**: Steps are executed based on their dependencies, allowing for parallel execution of independent steps.
|
|
@@ -62,6 +62,7 @@ A dynamic, dependency-resolving saga orchestrator for Ruby. Ruby Reactor impleme
|
|
|
62
62
|
- [Complex Workflows with Dependencies](#complex-workflows-with-dependencies)
|
|
63
63
|
- [Error Handling and Compensation](#error-handling-and-compensation)
|
|
64
64
|
- [Using Pre-defined Schemas](#using-pre-defined-schemas)
|
|
65
|
+
- [Testing](#testing)
|
|
65
66
|
- [Documentation](#documentation)
|
|
66
67
|
- [Future improvements](#future-improvements)
|
|
67
68
|
- [Development](#development)
|
|
@@ -680,6 +681,29 @@ class SchemaValidatedReactor < RubyReactor::Reactor
|
|
|
680
681
|
end
|
|
681
682
|
```
|
|
682
683
|
|
|
684
|
+
### Testing
|
|
685
|
+
|
|
686
|
+
RubyReactor provides testing utilities for RSpec. See the [Testing with RSpec](documentation/testing.md) guide for comprehensive documentation.
|
|
687
|
+
|
|
688
|
+
```ruby
|
|
689
|
+
RSpec.describe PaymentReactor do
|
|
690
|
+
it "processes payment successfully" do
|
|
691
|
+
subject = test_reactor(PaymentReactor, order_id: 123, amount: 99.99)
|
|
692
|
+
|
|
693
|
+
expect(subject).to be_success
|
|
694
|
+
expect(subject).to have_run_step(:charge_card).after(:validate_order)
|
|
695
|
+
expect(subject.step_result(:charge_card)).to include(status: "completed")
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
it "handles payment failures with mocked steps" do
|
|
699
|
+
subject = test_reactor(PaymentReactor, order_id: 123, amount: 99.99)
|
|
700
|
+
.mock_step(:charge_card) { Failure("Card declined") }
|
|
701
|
+
|
|
702
|
+
expect(subject).to be_failure
|
|
703
|
+
expect(subject.error).to include("Card declined")
|
|
704
|
+
end
|
|
705
|
+
end
|
|
706
|
+
```
|
|
683
707
|
|
|
684
708
|
## Documentation
|
|
685
709
|
|
|
@@ -706,6 +730,9 @@ Configure robust retry policies for your steps. This guide details the available
|
|
|
706
730
|
### [Interrupts](documentation/interrupts.md)
|
|
707
731
|
Learn how to pause and resume reactors to handle long-running processes, manual approvals, and asynchronous callbacks. Patterns for correlation IDs, timeouts, and payload validation.
|
|
708
732
|
|
|
733
|
+
### [Testing with RSpec](documentation/testing.md)
|
|
734
|
+
Comprehensive guide to testing reactors with RubyReactor's testing utilities. Learn about the `TestSubject` class for reactor execution and introspection, step mocking for isolating dependencies, testing nested and composed reactors, and custom RSpec matchers like `be_success`, `have_run_step`, and `have_retried_step`.
|
|
735
|
+
|
|
709
736
|
### Examples
|
|
710
737
|
- [Order Processing](documentation/examples/order_processing.md) - Complete order processing workflow example
|
|
711
738
|
- [Payment Processing](documentation/examples/payment_processing.md) - Payment handling with compensation
|