smart_message 0.0.13 → 0.0.17
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/.gitignore +1 -0
- data/CHANGELOG.md +184 -0
- data/Gemfile.lock +6 -6
- data/README.md +75 -25
- data/docs/guides/transport-selection.md +361 -0
- data/docs/index.md +2 -0
- data/docs/reference/transports.md +78 -29
- data/docs/transports/file-transport.md +535 -0
- data/docs/transports/memory-transport.md +2 -1
- data/docs/transports/multi-transport.md +484 -0
- data/docs/transports/redis-transport.md +1 -1
- data/docs/transports/stdout-transport.md +580 -0
- data/examples/file/00_run_all_file_demos.rb +260 -0
- data/examples/file/01_basic_file_transport_demo.rb +237 -0
- data/examples/file/02_fifo_transport_demo.rb +289 -0
- data/examples/file/03_file_watching_demo.rb +332 -0
- data/examples/file/04_multi_transport_file_demo.rb +432 -0
- data/examples/file/README.md +257 -0
- data/examples/memory/00_run_all_demos.rb +317 -0
- data/examples/memory/01_message_deduplication_demo.rb +18 -30
- data/examples/memory/02_dead_letter_queue_demo.rb +9 -9
- data/examples/memory/03_point_to_point_orders.rb +3 -3
- data/examples/memory/04_publish_subscribe_events.rb +15 -15
- data/examples/memory/05_many_to_many_chat.rb +19 -19
- data/examples/memory/06_stdout_publish_only.rb +118 -0
- data/examples/memory/07_proc_handlers_demo.rb +13 -13
- data/examples/memory/08_custom_logger_demo.rb +136 -136
- data/examples/memory/09_error_handling_demo.rb +7 -7
- data/examples/memory/10_entity_addressing_basic.rb +25 -25
- data/examples/memory/11_entity_addressing_with_filtering.rb +32 -32
- data/examples/memory/12_regex_filtering_microservices.rb +10 -10
- data/examples/memory/14_global_configuration_demo.rb +12 -12
- data/examples/memory/README.md +34 -17
- data/examples/memory/log/demo_app.log.2 +100 -0
- data/examples/multi_transport_example.rb +114 -0
- data/examples/redis/01_smart_home_iot_demo.rb +20 -20
- data/examples/utilities/box_it.rb +12 -0
- data/examples/utilities/doing.rb +19 -0
- data/examples/utilities/temp.md +28 -0
- data/lib/smart_message/base.rb +5 -7
- data/lib/smart_message/errors.rb +3 -0
- data/lib/smart_message/header.rb +1 -1
- data/lib/smart_message/logger/default.rb +1 -1
- data/lib/smart_message/messaging.rb +36 -6
- data/lib/smart_message/plugins.rb +46 -4
- data/lib/smart_message/serializer/base.rb +1 -1
- data/lib/smart_message/serializer.rb +3 -2
- data/lib/smart_message/subscription.rb +18 -20
- data/lib/smart_message/transport/async_publish_queue.rb +284 -0
- data/lib/smart_message/transport/fifo_operations.rb +264 -0
- data/lib/smart_message/transport/file_operations.rb +232 -0
- data/lib/smart_message/transport/file_transport.rb +152 -0
- data/lib/smart_message/transport/file_watching.rb +72 -0
- data/lib/smart_message/transport/partitioned_files.rb +46 -0
- data/lib/smart_message/transport/stdout_transport.rb +7 -81
- data/lib/smart_message/transport/stdout_transport.rb.backup +88 -0
- data/lib/smart_message/version.rb +1 -1
- data/mkdocs.yml +4 -5
- metadata +26 -10
- data/ideas/README.md +0 -41
- data/ideas/agents.md +0 -1001
- data/ideas/database_transport.md +0 -980
- data/ideas/improvement.md +0 -359
- data/ideas/meshage.md +0 -1788
- data/ideas/message_discovery.md +0 -178
- data/ideas/message_schema.md +0 -1381
- data/lib/smart_message/wrapper.rb.bak +0 -132
- /data/examples/memory/{06_pretty_print_demo.rb → 16_pretty_print_demo.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31da3cbbad04e7c1c5c6c4957e9cbe19fd2b5ef3b4eb13079f6daa5056cf5f93
|
4
|
+
data.tar.gz: f418df55d5e4e40b8ad942eec2c553ae6f6275a85a1a1fe8063addcee8ddc2f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72876daadfbf2d4bc817ceaa0e41d5564e537a4baf71b36fb4042ed217c63802bf1500ff51bdcce9b19c8765ad9be2a7d8e6fbc288e937ec30a64334fa5e3d1f
|
7
|
+
data.tar.gz: e663de462e0221c88ca90352ef11861b99b7ed43b43a941899e67b9dfc584c68a1af9c2b86a5f09188fd2ee528308869eb92a267920bdf8fc52e197e30c1eb91
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,190 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.0.17] 2025-09-11
|
11
|
+
|
12
|
+
### Enhanced
|
13
|
+
- **FileTransport Message Handling**: Simplified FileTransport publish method to only handle message objects
|
14
|
+
- **Architecture Clarification**: FileTransport now exclusively accepts SmartMessage objects with `_sm_header`
|
15
|
+
- **Message Processing**: Proper extraction of message class from `message._sm_header.message_class`
|
16
|
+
- **Serialization Flow**: Clean serialization pipeline using `encode_message(message)` before file operations
|
17
|
+
- **Code Quality**: Eliminated unnecessary backward compatibility code for raw string payloads
|
18
|
+
- **Demo Program Simplification**: Streamlined 06 demo with minimal message properties
|
19
|
+
- **Property Reduction**: DemoMessage now uses only `first_name` and `last_name` properties for clarity
|
20
|
+
- **Format Examples**: Three clear format demonstrations (Alice Johnson in :pretty, Bob Smith & Carol Williams in :jsonl, David Brown, Emma Davis & Frank Miller in :json)
|
21
|
+
- **Educational Value**: Simplified output makes format differences more apparent and easier to understand
|
22
|
+
- **Documentation Updates**: Updated usage examples and JQ query patterns to reflect simple property structure
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
- **FileTransport Test Compatibility**: Removed invalid compatibility test for raw string publishing
|
26
|
+
- **Issue**: Test `test_publish_compatibility_method` was passing raw strings to FileTransport.publish
|
27
|
+
- **Architecture Decision**: FileTransport should only handle SmartMessage objects, not raw strings
|
28
|
+
- **Solution**: Removed the invalid test that conflicted with proper message object architecture
|
29
|
+
- **Impact**: Test suite now properly validates FileTransport's message-only publishing contract
|
30
|
+
- **StdoutTransport Architecture**: Simplified StdoutTransport to minimal subclass of FileTransport
|
31
|
+
- **Inheritance**: StdoutTransport now inherits all functionality from FileTransport with minimal 6-line implementation
|
32
|
+
- **Option Merging**: Fixed critical bug where `file_path: $stdout` always overwrote user-provided options
|
33
|
+
- **Solution**: Changed from `options.merge(defaults)` to `defaults.merge(options)` for proper option precedence
|
34
|
+
- **Flexibility**: StdoutTransport can now write to files when `file_path` option is provided, while defaulting to STDOUT
|
35
|
+
- **FileTransport Format Support**: Added comprehensive output formatting capabilities to FileTransport
|
36
|
+
- **Format Options**: Implemented `:json` (raw), `:jsonl` (JSON with newline), and `:pretty` (amazing_print formatting)
|
37
|
+
- **Pretty Printing**: Added amazing_print integration for `:pretty` format using serializer's `decode` method
|
38
|
+
- **Serializer Integration**: Pretty format uses transport's serializer to deserialize messages back to Ruby objects
|
39
|
+
- **Fallback Handling**: Graceful fallback to raw output when amazing_print is unavailable or deserialization fails
|
40
|
+
- **FileTransport IO Object Support**: Enhanced FileTransport to handle IO objects properly
|
41
|
+
- **IO Detection**: Added `respond_to?(:write)` checks to distinguish IO objects from file paths
|
42
|
+
- **Directory Operations**: Skip directory creation for IO objects in `ensure_directory_exists`
|
43
|
+
- **File Operations**: Return IO objects directly in `open_file_handle` instead of trying to open them
|
44
|
+
- **Compatibility**: Maintains full backward compatibility with string file paths
|
45
|
+
|
46
|
+
### Fixed
|
47
|
+
- **StdoutTransport Option Precedence**: Fixed critical configuration bug preventing file output
|
48
|
+
- **Issue**: `super(options.merge(file_path: $stdout))` caused defaults to always override user options
|
49
|
+
- **Impact**: StdoutTransport could not write to files when `file_path` was provided
|
50
|
+
- **Fix**: Reversed merge order to `defaults.merge(options)` for proper option precedence
|
51
|
+
- **Result**: StdoutTransport now correctly respects user-provided file paths while defaulting to STDOUT
|
52
|
+
- **FileOperations Type Safety**: Enhanced type checking for file vs IO operations
|
53
|
+
- **Issue**: `File.dirname` called on IO objects caused "no implicit conversion" errors
|
54
|
+
- **Solution**: Added `respond_to?(:write)` checks throughout FileOperations module
|
55
|
+
- **Methods Fixed**: `ensure_directory_exists`, `open_file_handle`, and related file operations
|
56
|
+
- **Robustness**: FileTransport now handles both file paths and IO objects seamlessly
|
57
|
+
|
58
|
+
### Added
|
59
|
+
- **Pretty Format Demo**: Enhanced STDOUT transport demo with comprehensive format examples
|
60
|
+
- **Demo Update**: `examples/memory/06_stdout_publish_only.rb` now demonstrates all three formats
|
61
|
+
- **Format Examples**: LogMessage (jsonl), MetricsMessage (json), and DebugMessage (pretty)
|
62
|
+
- **Complex Data**: DebugMessage showcases pretty formatting with nested data structures
|
63
|
+
- **Educational Value**: Clear documentation of format differences and use cases
|
64
|
+
|
65
|
+
### Tests
|
66
|
+
- **Complete Test Suite**: All transport tests now pass without errors
|
67
|
+
- **Test Results**: 313 runs, 930 assertions, 0 failures, 0 errors, 27 skips
|
68
|
+
- **StdoutTransport Tests**: Fixed all TypeError issues related to IO object handling
|
69
|
+
- **FileTransport Integration**: Verified format support and IO object compatibility
|
70
|
+
- **Test Cleanup**: Removed invalid test that attempted to publish raw strings to FileTransport
|
71
|
+
- **Architecture Validation**: Test suite now properly validates message-only publishing contract
|
72
|
+
- **Regression Prevention**: Test coverage ensures option merging bug cannot reoccur
|
73
|
+
|
74
|
+
## [0.0.16] 2025-09-10
|
75
|
+
|
76
|
+
### Added
|
77
|
+
- **FileTransport Demo Suite**: Comprehensive demonstration programs for FileTransport functionality
|
78
|
+
- **Basic FileTransport Demo** (`examples/file/01_basic_file_transport_demo.rb`): Complete demonstration of core FileTransport features including different output formats (JSON, YAML, raw), append vs overwrite modes, custom serialization, and file rotation examples
|
79
|
+
- **FIFO Transport Demo** (`examples/file/02_fifo_transport_demo.rb`): FIFO (named pipe) demonstrations covering FIFO creation, properties, and concepts with educational content about inter-process communication
|
80
|
+
- **File Watching Demo** (`examples/file/03_file_watching_demo.rb`): File monitoring and change detection examples with polling-based file watching
|
81
|
+
- **Multi-Transport File Demo** (`examples/file/04_multi_transport_file_demo.rb`): Advanced patterns including fan-out to multiple files, conditional routing, multi-transport combinations, archival strategies, and performance monitoring
|
82
|
+
- **Interactive Demo Runner** (`examples/file/00_run_all_file_demos.rb`): Menu-driven demo launcher with comprehensive error handling and user-friendly navigation
|
83
|
+
|
84
|
+
### Fixed
|
85
|
+
- **Demo Configuration Syntax**: Fixed incorrect `.configure` method usage throughout FileTransport demos
|
86
|
+
- **Issue**: Demos were using non-existent `MessageClass.configure` method causing "undefined method 'configure'" errors
|
87
|
+
- **Solution**: Updated all configuration calls to use `MessageClass.class_eval { transport transport_instance }` pattern consistent with working examples
|
88
|
+
- **Files Updated**: All FileTransport demo files now use correct transport configuration syntax
|
89
|
+
- **Message Instantiation Arguments**: Fixed keyword argument errors in message creation
|
90
|
+
- **Issue**: Hash variables being passed to `MessageClass.new(hash_var)` instead of using keyword argument expansion
|
91
|
+
- **Solution**: Updated all message instantiation calls to use `MessageClass.new(**hash_var)` for proper keyword argument passing
|
92
|
+
- **Impact**: Resolves "wrong number of arguments (given 1, expected 0)" errors throughout demo suite
|
93
|
+
- **Method Name Consistency**: Updated all demo files to use correct `publish` method instead of deprecated `send`
|
94
|
+
- **Issue**: Some demos were using `.send` method which is not the correct SmartMessage publishing method
|
95
|
+
- **Solution**: Replaced all instances of `.send` with `.publish` across FileTransport demos
|
96
|
+
- **Files Affected**: 02_fifo_transport_demo.rb, 04_multi_transport_file_demo.rb
|
97
|
+
- **Missing `from` Property Declarations**: Added required `from` declarations to all message classes
|
98
|
+
- **Issue**: Message classes missing required `from` property causing "The property 'from' From entity ID is required" errors
|
99
|
+
- **Solution**: Added `from 'demo_source'` declarations to all message class definitions including dynamically created classes
|
100
|
+
- **Impact**: Ensures proper message routing and header initialization
|
101
|
+
- **FIFO Blocking Issues**: Resolved program hanging when writing to FIFOs without concurrent readers
|
102
|
+
- **Issue**: FIFO operations block indefinitely when no reader process is available
|
103
|
+
- **Solution**: Simplified FIFO examples to demonstrate FIFO concepts and properties without blocking operations, replaced complex multi-process examples with educational demonstrations
|
104
|
+
- **Result**: Demos now complete successfully without hanging while still teaching FIFO fundamentals
|
105
|
+
- **Variable Scope Issues**: Fixed transport variable accessibility problems in custom routing logic
|
106
|
+
- **Issue**: Complex custom routing classes couldn't access transport variables from outer scope
|
107
|
+
- **Solution**: Simplified conditional routing examples to use separate message classes for different severity levels instead of dynamic transport switching
|
108
|
+
- **Benefit**: Cleaner, more maintainable code that demonstrates routing concepts without scope complications
|
109
|
+
|
110
|
+
### Enhanced
|
111
|
+
- **Demo Educational Value**: Improved all FileTransport demos with comprehensive documentation and error handling
|
112
|
+
- **Documentation**: Added detailed comments explaining FileTransport concepts, FIFO characteristics, and usage patterns
|
113
|
+
- **Error Handling**: Enhanced error reporting and graceful degradation in all demo scenarios
|
114
|
+
- **User Experience**: Simplified complex examples to focus on core functionality while maintaining educational value
|
115
|
+
- **Output Clarity**: Improved console output formatting and messaging for better understanding of demo operations
|
116
|
+
|
117
|
+
### Documentation
|
118
|
+
- **FileTransport Demo README**: Comprehensive documentation for all FileTransport demonstration programs
|
119
|
+
- **Usage Instructions**: Step-by-step guide for running individual demos and the interactive demo runner
|
120
|
+
- **Concept Explanations**: Detailed explanations of FileTransport features, FIFO operations, and advanced patterns
|
121
|
+
- **Troubleshooting**: Common issues and solutions for FileTransport usage
|
122
|
+
- **Example Outputs**: Sample console outputs showing expected demo results
|
123
|
+
|
124
|
+
## [0.0.15] 2025-09-10
|
125
|
+
|
126
|
+
### Added
|
127
|
+
- **Multi-Transport Publishing**: Messages can now be configured to publish to multiple transports simultaneously
|
128
|
+
- **Core Feature**: Configure messages with an array of transports using `transport [transport1, transport2, transport3]` syntax
|
129
|
+
- **Resilient Publishing**: Publishing succeeds if ANY configured transport works; only fails if ALL transports fail
|
130
|
+
- **Error Handling**: Individual transport failures are logged but don't prevent publishing to remaining transports
|
131
|
+
- **Backward Compatibility**: Single transport configuration continues to work unchanged (`transport single_transport`)
|
132
|
+
- **Utility Methods**: Added `transports()`, `single_transport?()`, and `multiple_transports?()` for transport introspection
|
133
|
+
- **Use Cases**: Supports redundancy, integration, migration, and fan-out messaging patterns
|
134
|
+
|
135
|
+
### Enhanced
|
136
|
+
- **Transport Configuration API**: Extended transport configuration methods to handle both single transports and transport arrays
|
137
|
+
- **Plugins Module**: Updated `transport()` method in `lib/smart_message/plugins.rb` to accept arrays while maintaining backward compatibility
|
138
|
+
- **Internal Storage**: Transport arrays stored internally but `transport()` getter returns first transport for existing code compatibility
|
139
|
+
- **Instance Overrides**: Instance-level transport configuration can override class-level multi-transport settings
|
140
|
+
- **Publishing Pipeline**: Enhanced message publishing in `lib/smart_message/messaging.rb` for multi-transport support
|
141
|
+
- **Parallel Publishing**: Iterates through all configured transports and publishes to each
|
142
|
+
- **Comprehensive Logging**: Logs successful and failed transports with detailed error information
|
143
|
+
- **Error Aggregation**: Collects all transport errors and raises `PublishError` only when all transports fail
|
144
|
+
- **Success Tracking**: Continues processing even when individual transports fail
|
145
|
+
|
146
|
+
### Added - Error Handling
|
147
|
+
- **PublishError**: New error class `SmartMessage::Errors::PublishError` for multi-transport failure scenarios
|
148
|
+
- **Condition**: Only raised when ALL configured transports fail to publish
|
149
|
+
- **Error Detail**: Aggregates error messages from all failed transports for comprehensive debugging
|
150
|
+
- **Added to**: `lib/smart_message/errors.rb`
|
151
|
+
|
152
|
+
### Added - Documentation
|
153
|
+
- **Comprehensive Guide**: Created `docs/transports/multi-transport.md` with complete multi-transport documentation
|
154
|
+
- **Real-World Examples**: High-availability, development/production dual publishing, monitoring integration, A/B testing
|
155
|
+
- **Best Practices**: Performance considerations, environment-specific configuration, health monitoring
|
156
|
+
- **Troubleshooting**: Common issues, debugging techniques, and solutions
|
157
|
+
- **Integration Updates**: Updated main transport documentation and index to reference multi-transport capability
|
158
|
+
- **Transport Layer**: Added multi-transport section to `docs/reference/transports.md`
|
159
|
+
- **Table of Contents**: Added multi-transport link to main documentation index
|
160
|
+
|
161
|
+
### Added - Testing
|
162
|
+
- **Comprehensive Test Suite**: Created `test/multi_transport_test.rb` with 12 test cases covering all functionality
|
163
|
+
- **Backward Compatibility**: Verified single transport behavior remains unchanged
|
164
|
+
- **Multi-Transport Scenarios**: Tests for successful publishing, partial failures, complete failures
|
165
|
+
- **Configuration Testing**: Class vs instance configuration, transport introspection, method chaining
|
166
|
+
- **Mock Transports**: Added `FailingTransport` and `CountingTransport` for controlled testing
|
167
|
+
- **Integration Tests**: Real transport combinations (Memory + STDOUT)
|
168
|
+
|
169
|
+
### Added - Examples
|
170
|
+
- **README Integration**: Added multi-transport example to main README.md with practical use case
|
171
|
+
- **Features Section**: Added multi-transport publishing bullet point to feature list
|
172
|
+
- **Transport Implementations**: Complete section with `CriticalOrderMessage` example showing 3 transports
|
173
|
+
- **Key Benefits**: Highlighted redundancy, integration, migration, and resilience benefits
|
174
|
+
- **Example File**: Created `examples/multi_transport_example.rb` demonstrating all multi-transport functionality
|
175
|
+
- **Usage Patterns**: Single transport (backward compatibility), multiple transports, instance overrides
|
176
|
+
- **Error Scenarios**: Partial transport failure resilience and complete failure handling
|
177
|
+
- **Utility Demonstrations**: Transport counting, type checking, and configuration inspection
|
178
|
+
|
179
|
+
## [0.0.14] 2025-09-10
|
180
|
+
|
181
|
+
### Fixed
|
182
|
+
- **Configuration Architecture**: Fixed `SmartMessage::Serializer.default` method to properly reflect transport-owned serialization architecture
|
183
|
+
- **Issue**: `SmartMessage::Serializer.default` was trying to access a non-existent `default_serializer` method on global configuration
|
184
|
+
- **Root Cause**: Serialization belongs to transports, not global configuration, but the method was attempting to check global config first
|
185
|
+
- **Solution**: Updated method to return framework default (`SmartMessage::Serializer::Json`) directly without depending on global configuration
|
186
|
+
- **Architecture Clarification**: Each transport owns and configures its own serializer (line 19 in transport/base.rb: `@serializer = options[:serializer] || default_serializer`)
|
187
|
+
- **Demo Fix**: Updated `examples/memory/14_global_configuration_demo.rb` to remove incorrect `config.serializer =` attempts and added architecture comments
|
188
|
+
- **Test Method Signatures**: Completed wrapper-to-message architecture transition by fixing remaining method signature issues
|
189
|
+
- **dispatcher_test.rb**: Changed `processer_one` and `processer_two` from instance methods to class methods (`def self.`)
|
190
|
+
- **Message Format**: Updated methods to use flat message structure (`message._sm_header.message_class` and `message.to_json`) instead of old two-tier format (`message_header, encoded_message = message`)
|
191
|
+
- **subscribe_test.rb**: Fixed `business_logic` method to be a class method (`def self.business_logic`) to match subscription call pattern
|
192
|
+
- **Result**: All tests now pass (`176 runs, 578 assertions, 0 failures, 0 errors, 1 skips`) completing the architectural transition
|
193
|
+
|
10
194
|
## [0.0.13] 2025-09-10
|
11
195
|
|
12
196
|
### Changed
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smart_message (0.0.
|
4
|
+
smart_message (0.0.17)
|
5
5
|
activesupport
|
6
6
|
async
|
7
7
|
async-redis
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
tzinfo (~> 2.0, >= 2.0.5)
|
31
31
|
uri (>= 0.13.1)
|
32
32
|
amazing_print (1.8.1)
|
33
|
-
async (2.
|
33
|
+
async (2.32.0)
|
34
34
|
console (~> 1.29)
|
35
35
|
fiber-annotation
|
36
36
|
io-event (~> 1.11)
|
@@ -47,10 +47,10 @@ GEM
|
|
47
47
|
base64 (0.3.0)
|
48
48
|
benchmark (0.4.1)
|
49
49
|
bigdecimal (3.2.3)
|
50
|
-
breaker_machines (0.
|
50
|
+
breaker_machines (0.5.0)
|
51
51
|
activesupport (>= 7.2)
|
52
52
|
concurrent-ruby (~> 1.3)
|
53
|
-
state_machines (>= 0.
|
53
|
+
state_machines (>= 0.100.0)
|
54
54
|
zeitwerk (~> 2.7)
|
55
55
|
colorize (1.1.0)
|
56
56
|
concurrent-ruby (1.3.5)
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
json (2.13.2)
|
75
75
|
logger (1.7.0)
|
76
76
|
lumberjack (1.4.1)
|
77
|
-
metrics (0.
|
77
|
+
metrics (0.15.0)
|
78
78
|
minitest (5.25.5)
|
79
79
|
minitest-power_assert (0.3.1)
|
80
80
|
minitest
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
rake (13.3.0)
|
86
86
|
redis (5.4.1)
|
87
87
|
redis-client (>= 0.22.0)
|
88
|
-
redis-client (0.25.
|
88
|
+
redis-client (0.25.3)
|
89
89
|
connection_pool
|
90
90
|
securerandom (0.4.1)
|
91
91
|
shoulda (4.0.0)
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Think of SmartMessage as ActiveRecord for messaging - just as ActiveRecord frees
|
|
23
23
|
## Features
|
24
24
|
|
25
25
|
- **Transport Abstraction**: Plugin architecture supporting multiple message transports (Redis, RabbitMQ, Kafka, etc.)
|
26
|
+
- **Multi-Transport Publishing**: Send messages to multiple transports simultaneously for redundancy, integration, and migration scenarios
|
26
27
|
- **🌟 Redis Queue Transport**: Advanced transport with RabbitMQ-style routing patterns, persistent FIFO queues, load balancing, and 10x faster performance than traditional message brokers. Built on Ruby's Async framework for fiber-based concurrency supporting thousands of concurrent subscriptions - [see full documentation](docs/transports/redis-queue.md)
|
27
28
|
- **Serialization Flexibility**: Pluggable serialization formats (JSON, MessagePack, etc.)
|
28
29
|
- **Entity-to-Entity Addressing**: Built-in FROM/TO/REPLY_TO addressing for point-to-point and broadcast messaging patterns
|
@@ -36,7 +37,7 @@ Think of SmartMessage as ActiveRecord for messaging - just as ActiveRecord frees
|
|
36
37
|
- **Advanced Logging System**: Comprehensive logging with colorized console output, JSON structured logging, and file rolling
|
37
38
|
- **Built-in Statistics**: Message processing metrics and monitoring
|
38
39
|
- **Message Deduplication**: Handler-scoped deduplication queues (DDQ) with memory or Redis storage for preventing duplicate message processing
|
39
|
-
- **Development Tools**: STDOUT and in-memory
|
40
|
+
- **Development Tools**: STDOUT transport for publish-only scenarios and in-memory transport for testing with local processing
|
40
41
|
- **Production Ready**: Redis transport with automatic reconnection and error handling
|
41
42
|
- **Dead Letter Queue**: File-based DLQ with JSON Lines format for failed message capture and replay
|
42
43
|
- **Circuit Breaker Integration**: Production-grade reliability with BreakerMachines for automatic fallback and recovery
|
@@ -131,8 +132,8 @@ class OrderMessage < SmartMessage::Base
|
|
131
132
|
|
132
133
|
# Configure transport and serializer at class level
|
133
134
|
config do
|
134
|
-
# Option 1:
|
135
|
-
transport SmartMessage::Transport.
|
135
|
+
# Option 1: Memory transport for local development with message processing
|
136
|
+
transport SmartMessage::Transport::MemoryTransport.new
|
136
137
|
|
137
138
|
# Option 2: Redis Queue for production (10x faster than RabbitMQ!)
|
138
139
|
# transport SmartMessage::Transport.create(:redis_queue,
|
@@ -196,24 +197,19 @@ OrderMessage.subscribe
|
|
196
197
|
OrderMessage.subscribe("PaymentService.process_order")
|
197
198
|
|
198
199
|
# 3. Block handler (NEW!)
|
199
|
-
OrderMessage.subscribe do |
|
200
|
-
|
201
|
-
order_data = JSON.parse(payload)
|
202
|
-
puts "Quick processing: Order #{order_data['order_id']}"
|
200
|
+
OrderMessage.subscribe do |message|
|
201
|
+
puts "Quick processing: Order #{message.order_id}"
|
203
202
|
end
|
204
203
|
|
205
204
|
# 4. Proc handler (NEW!)
|
206
|
-
order_processor = proc do |
|
207
|
-
|
208
|
-
order_data = JSON.parse(payload)
|
209
|
-
EmailService.send_confirmation(order_data['customer_id'])
|
205
|
+
order_processor = proc do |message|
|
206
|
+
EmailService.send_confirmation(message.customer_id)
|
210
207
|
end
|
211
208
|
OrderMessage.subscribe(order_processor)
|
212
209
|
|
213
210
|
# 5. Lambda handler (NEW!)
|
214
|
-
audit_handler = lambda do |
|
215
|
-
|
216
|
-
AuditLog.record("Order processed at #{header.published_at}")
|
211
|
+
audit_handler = lambda do |message|
|
212
|
+
AuditLog.record("Order processed at #{message._sm_header.published_at}")
|
217
213
|
end
|
218
214
|
OrderMessage.subscribe(audit_handler)
|
219
215
|
```
|
@@ -542,8 +538,8 @@ The foundation class that all messages inherit from. Built on `Hashie::Dash` wit
|
|
542
538
|
#### Transport Layer
|
543
539
|
Pluggable message delivery system with built-in implementations:
|
544
540
|
|
545
|
-
- **StdoutTransport**:
|
546
|
-
- **MemoryTransport**: In-memory queuing for testing
|
541
|
+
- **StdoutTransport**: Publish-only transport for debugging and external integration
|
542
|
+
- **MemoryTransport**: In-memory queuing for testing with local message processing
|
547
543
|
- **RedisTransport**: Redis pub/sub transport for production messaging
|
548
544
|
- **Custom Transports**: Implement `SmartMessage::Transport::Base`
|
549
545
|
|
@@ -586,6 +582,38 @@ This enables gateway patterns where messages can be received from one transport/
|
|
586
582
|
|
587
583
|
## Transport Implementations
|
588
584
|
|
585
|
+
### Multi-Transport Messages
|
586
|
+
|
587
|
+
SmartMessage supports publishing to multiple transports simultaneously for redundancy, integration, and migration scenarios:
|
588
|
+
|
589
|
+
```ruby
|
590
|
+
class CriticalOrderMessage < SmartMessage::Base
|
591
|
+
property :order_id, required: true
|
592
|
+
property :amount, required: true
|
593
|
+
|
594
|
+
# Configure multiple transports - message goes to ALL of them
|
595
|
+
transport [
|
596
|
+
SmartMessage::Transport.create(:redis_queue, url: 'redis://primary:6379'),
|
597
|
+
SmartMessage::Transport.create(:redis, url: 'redis://backup:6379'),
|
598
|
+
SmartMessage::Transport::StdoutTransport.new(format: :json)
|
599
|
+
]
|
600
|
+
end
|
601
|
+
|
602
|
+
# Publishes to Redis Queue, Redis Pub/Sub, and STDOUT simultaneously
|
603
|
+
message = CriticalOrderMessage.new(order_id: "ORD-123", amount: 99.99)
|
604
|
+
message.publish # ✅ Succeeds if ANY transport works
|
605
|
+
|
606
|
+
# Check transport configuration
|
607
|
+
puts message.multiple_transports? # => true
|
608
|
+
puts message.transports.length # => 3
|
609
|
+
```
|
610
|
+
|
611
|
+
**Key Benefits:**
|
612
|
+
- **Redundancy**: Messages reach multiple destinations for reliability
|
613
|
+
- **Integration**: Simultaneously log to STDOUT, send to Redis, and webhook external systems
|
614
|
+
- **Migration**: Gradually transition between transport systems
|
615
|
+
- **Resilient**: Publishing succeeds as long as ANY transport works
|
616
|
+
|
589
617
|
### Redis Queue Transport (Featured) 🌟
|
590
618
|
|
591
619
|
The Redis Queue Transport provides enterprise-grade message routing with exceptional performance:
|
@@ -637,17 +665,39 @@ OrderMessage.new(
|
|
637
665
|
|
638
666
|
📚 **Full Documentation:** [Redis Queue Transport Guide](docs/transports/redis-queue.md) | [Getting Started](docs/guides/redis-queue-getting-started.md) | [Examples](examples/redis_queue/)
|
639
667
|
|
640
|
-
### STDOUT Transport (
|
668
|
+
### STDOUT Transport (Publish-Only)
|
669
|
+
|
670
|
+
The STDOUT transport is designed for publish-only scenarios - perfect for debugging, logging, or integration with external systems. Built as a minimal subclass of FileTransport, it inherits comprehensive formatting capabilities.
|
641
671
|
|
642
672
|
```ruby
|
643
|
-
# Basic STDOUT output
|
644
|
-
transport = SmartMessage::Transport.
|
673
|
+
# Basic STDOUT output (publish-only)
|
674
|
+
transport = SmartMessage::Transport::StdoutTransport.new
|
675
|
+
|
676
|
+
# JSON Lines format - one message per line (default)
|
677
|
+
transport = SmartMessage::Transport::StdoutTransport.new(format: :jsonl)
|
645
678
|
|
646
|
-
#
|
647
|
-
transport = SmartMessage::Transport.
|
679
|
+
# Pretty-printed format with amazing_print for human reading
|
680
|
+
transport = SmartMessage::Transport::StdoutTransport.new(format: :pretty)
|
648
681
|
|
649
|
-
#
|
650
|
-
transport = SmartMessage::Transport.
|
682
|
+
# Compact JSON format without newlines
|
683
|
+
transport = SmartMessage::Transport::StdoutTransport.new(format: :json)
|
684
|
+
|
685
|
+
# Output to file instead of STDOUT
|
686
|
+
transport = SmartMessage::Transport::StdoutTransport.new(file_path: "messages.log")
|
687
|
+
```
|
688
|
+
|
689
|
+
**Key Features:**
|
690
|
+
- **Publish-only**: No message processing or loopback
|
691
|
+
- **Subscription attempts are ignored** with warning logs
|
692
|
+
- **Three formats**: `:jsonl` (default), `:pretty` for debugging, `:json` for compact output
|
693
|
+
- **Flexible Output**: Defaults to STDOUT but can write to files when `file_path` specified
|
694
|
+
- **Perfect for**: debugging, logging, piping to external tools
|
695
|
+
- **Use cases**: `./app | jq '.first_name'`, `./app | fluentd`, development monitoring
|
696
|
+
|
697
|
+
**For local message processing, use MemoryTransport instead:**
|
698
|
+
```ruby
|
699
|
+
# Use Memory transport if you need local message processing
|
700
|
+
transport = SmartMessage::Transport::MemoryTransport.new
|
651
701
|
```
|
652
702
|
|
653
703
|
### Memory Transport (Testing)
|
@@ -952,8 +1002,8 @@ You can also set descriptions within configuration blocks:
|
|
952
1002
|
class ConfiguredMessage < SmartMessage::Base
|
953
1003
|
config do
|
954
1004
|
description "Set within config block"
|
955
|
-
transport SmartMessage::Transport.
|
956
|
-
serializer SmartMessage::Serializer::
|
1005
|
+
transport SmartMessage::Transport::MemoryTransport.new
|
1006
|
+
serializer SmartMessage::Serializer::Json.new
|
957
1007
|
end
|
958
1008
|
end
|
959
1009
|
```
|