jetstream_bridge 4.4.0 → 4.5.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 +92 -337
- data/README.md +1 -5
- data/docs/GETTING_STARTED.md +11 -7
- data/docs/PRODUCTION.md +51 -11
- data/docs/TESTING.md +24 -35
- data/lib/generators/jetstream_bridge/health_check/health_check_generator.rb +1 -1
- data/lib/generators/jetstream_bridge/initializer/initializer_generator.rb +1 -1
- data/lib/generators/jetstream_bridge/initializer/templates/jetstream_bridge.rb +0 -4
- data/lib/generators/jetstream_bridge/install/install_generator.rb +5 -5
- data/lib/generators/jetstream_bridge/migrations/migrations_generator.rb +2 -2
- data/lib/jetstream_bridge/consumer/consumer.rb +34 -96
- data/lib/jetstream_bridge/consumer/health_monitor.rb +107 -0
- data/lib/jetstream_bridge/consumer/message_processor.rb +1 -1
- data/lib/jetstream_bridge/consumer/subscription_manager.rb +51 -34
- data/lib/jetstream_bridge/core/config.rb +153 -46
- data/lib/jetstream_bridge/core/connection_manager.rb +513 -0
- data/lib/jetstream_bridge/core/debug_helper.rb +9 -3
- data/lib/jetstream_bridge/core/health_checker.rb +184 -0
- data/lib/jetstream_bridge/core.rb +0 -2
- data/lib/jetstream_bridge/facade.rb +212 -0
- data/lib/jetstream_bridge/publisher/event_envelope_builder.rb +110 -0
- data/lib/jetstream_bridge/publisher/publisher.rb +87 -117
- data/lib/jetstream_bridge/rails/integration.rb +8 -5
- data/lib/jetstream_bridge/rails/railtie.rb +4 -3
- data/lib/jetstream_bridge/tasks/install.rake +0 -1
- data/lib/jetstream_bridge/topology/topology.rb +6 -1
- data/lib/jetstream_bridge/version.rb +1 -1
- data/lib/jetstream_bridge.rb +206 -297
- metadata +7 -5
- data/lib/jetstream_bridge/core/bridge_helpers.rb +0 -109
- data/lib/jetstream_bridge/core/connection.rb +0 -464
- data/lib/jetstream_bridge/core/connection_factory.rb +0 -100
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f7e89386a56dac571dddec4c9d5283a975a8354d17d8f953ba148d390d55652
|
|
4
|
+
data.tar.gz: 64d5a7ea6bfdf863ea6a24d7d922cfaca565247605860cd999d6c2a8c893f48d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c95e0b2a4b829637f6c790cf13e710f814d085298949aadd141220d065cedc47dcd44a46fe8576b0cd280cd343cfd2a959ab4abb842fd0434cb817f9d70f9021
|
|
7
|
+
data.tar.gz: ebd5322b78df46177d3395c08674a822fd0cbf2a7111b7fbd7b4405f08ccaa7308d602ed0bcab862f4589730fe3a78c8b611c83d3eb0771eca199da31c0dc118
|
data/CHANGELOG.md
CHANGED
|
@@ -5,430 +5,185 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [4.
|
|
8
|
+
## [4.5.0] - 2026-01-22
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Dedicated `HealthChecker` service for comprehensive health monitoring
|
|
13
|
+
- `ConsumerHealthMonitor` for long-running consumer health tracking
|
|
14
|
+
- Stream name configuration now required (no more auto-generated defaults)
|
|
9
15
|
|
|
10
16
|
### Changed
|
|
11
17
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
- Refactored architecture with `Facade` pattern for cleaner API delegation
|
|
19
|
+
- Consolidated connection management into `ConnectionManager`
|
|
20
|
+
- Extracted health checking logic from connection layer into dedicated service
|
|
21
|
+
- Simplified documentation focusing on library features over implementation details
|
|
22
|
+
|
|
23
|
+
### Removed
|
|
24
|
+
|
|
25
|
+
- Removed `Connection` (refactored to `ConnectionManager`)
|
|
26
|
+
- Removed `BridgeHelpers` module (functionality distributed to appropriate layers)
|
|
27
|
+
- Removed auto-generated stream names (explicit configuration required)
|
|
28
|
+
|
|
29
|
+
## [4.4.1] - 2026-01-16
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Fixed Rails generator constant qualification to prevent NameError during load
|
|
34
|
+
|
|
35
|
+
## [4.4.0] - 2025-11-24
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
17
38
|
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
- More reliable detection of Rake execution context
|
|
21
|
-
- Prevents false positives when Rake is loaded but not executing
|
|
39
|
+
- Enhanced NATS round-trip time measurement with automatic fallback for clients without native `rtt` method
|
|
40
|
+
- Improved Rails Rake task detection using `$PROGRAM_NAME` inspection
|
|
22
41
|
|
|
23
42
|
### Fixed
|
|
24
43
|
|
|
25
|
-
-
|
|
26
|
-
- Added complete test coverage for Rails integration lifecycle methods
|
|
27
|
-
- Added tests for test helper matchers (`have_published`, `be_publish_success`, `be_publish_failure`)
|
|
28
|
-
- Added tests for fixture builders (`sample_event`, `sample_events`, `event`)
|
|
29
|
-
- Added test for RTT fallback behavior when client lacks `rtt` method
|
|
30
|
-
- Added spec file for `bridge_helpers` module
|
|
44
|
+
- Expanded test coverage for Rails integration and test helpers
|
|
31
45
|
|
|
32
46
|
## [4.3.0] - 2025-11-24
|
|
33
47
|
|
|
34
48
|
### Added
|
|
35
49
|
|
|
36
|
-
-
|
|
37
|
-
- `last_reconnect_error` and `last_reconnect_error_at` now publicly accessible
|
|
38
|
-
- Enables better monitoring and diagnostics of connection issues
|
|
39
|
-
- Added test coverage for diagnostic accessor visibility
|
|
50
|
+
- Exposed reconnection error tracking via `last_reconnect_error` and `last_reconnect_error_at` for better diagnostics
|
|
40
51
|
|
|
41
52
|
### Changed
|
|
42
53
|
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- `fetch_stream_info` now ensures connection is established before querying
|
|
47
|
-
- More reliable initialization sequence for non-Rails applications
|
|
48
|
-
|
|
49
|
-
- **Rails Integration** - Changed console autostart behavior
|
|
50
|
-
- Rails console now autostarts JetStream Bridge by default (previously skipped)
|
|
51
|
-
- Simplified autostart logic by removing console detection as skip condition
|
|
52
|
-
- Autostart remains disabled only for rake tasks (unless forced with `JETSTREAM_BRIDGE_FORCE_AUTOSTART`)
|
|
53
|
-
- Better developer experience in Rails console for immediate testing
|
|
54
|
-
|
|
55
|
-
- **Documentation** - Clarified connection initialization behavior
|
|
56
|
-
- Added notes explaining that `configure` only sets options and does not connect
|
|
57
|
-
- Documented when connection actually occurs (Rails: after initialization; non-Rails: call `startup!`)
|
|
58
|
-
- Improved explanation of `lazy_connect` behavior in Rails environments
|
|
59
|
-
- Added guidance for non-Rails applications to call `startup!` explicitly
|
|
54
|
+
- Improved topology management during startup and connection initialization
|
|
55
|
+
- Rails console now autostarts JetStream Bridge by default (autostart remains disabled for rake tasks)
|
|
56
|
+
- Updated documentation to clarify connection initialization behavior
|
|
60
57
|
|
|
61
58
|
### Fixed
|
|
62
59
|
|
|
63
|
-
-
|
|
64
|
-
- Added tests for topology ensuring in `startup!` and `connect_and_ensure_stream!`
|
|
65
|
-
- Added tests for connection initialization in `stream_info`
|
|
66
|
-
- Updated Rails integration specs to reflect new console behavior
|
|
60
|
+
- Expanded test coverage for topology management and Rails integration
|
|
67
61
|
|
|
68
62
|
## [4.2.0] - 2025-11-24
|
|
69
63
|
|
|
70
64
|
### Added
|
|
71
65
|
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- Improved separation of concerns and code discoverability
|
|
76
|
-
- Better namespace organization for future extensibility
|
|
77
|
-
|
|
78
|
-
- **Enhanced Test Helpers** - Comprehensive testing utilities split into focused modules
|
|
79
|
-
- `JetstreamBridge::TestHelpers::Fixtures` - Convenient fixture generation for events and messages
|
|
80
|
-
- `JetstreamBridge::TestHelpers::IntegrationHelpers` - Full NATS message simulation for integration tests
|
|
81
|
-
- `JetstreamBridge::TestHelpers::Matchers` - RSpec matchers for event publishing assertions
|
|
82
|
-
- Improved test doubles with realistic NATS message structure
|
|
83
|
-
- Better support for testing event-driven Rails applications
|
|
84
|
-
|
|
85
|
-
- **Getting Started Guide** - New comprehensive guide in `docs/GETTING_STARTED.md`
|
|
86
|
-
- Quick installation and setup instructions
|
|
87
|
-
- Publishing and consuming examples
|
|
88
|
-
- Rails integration patterns
|
|
89
|
-
- Links to advanced documentation
|
|
66
|
+
- Restructured codebase with `JetstreamBridge::Core` and `JetstreamBridge::Rails` modules
|
|
67
|
+
- Enhanced test helpers with fixtures, integration helpers, and RSpec matchers
|
|
68
|
+
- New Getting Started guide in `docs/GETTING_STARTED.md`
|
|
90
69
|
|
|
91
70
|
### Changed
|
|
92
71
|
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- `JetstreamBridge::Rails::Integration` - Autostart logic and Rails environment detection
|
|
97
|
-
- Cleaner separation between gem core and Rails integration
|
|
98
|
-
|
|
99
|
-
- **Documentation** - Restructured README for clarity
|
|
100
|
-
- Condensed README focusing on quick start and highlights
|
|
101
|
-
- Moved detailed guides to dedicated docs directory
|
|
102
|
-
- Improved navigation with links to specialized documentation
|
|
103
|
-
- More concise examples and clearer feature descriptions
|
|
104
|
-
|
|
105
|
-
- **Gemspec** - Enhanced package configuration
|
|
106
|
-
- Added `docs/**/*.md` to distributed files
|
|
107
|
-
- Added `extra_rdoc_files` for better documentation
|
|
108
|
-
- Updated description to emphasize production-readiness
|
|
72
|
+
- Reorganized Rails integration code into dedicated directory structure
|
|
73
|
+
- Restructured README for clarity with focus on quick start
|
|
74
|
+
- Enhanced gemspec with documentation files
|
|
109
75
|
|
|
110
76
|
### Fixed
|
|
111
77
|
|
|
112
|
-
-
|
|
113
|
-
- Fixed string literal consistency issues
|
|
114
|
-
- Improved code formatting and indentation
|
|
115
|
-
- Reduced complexity in conditional assignments
|
|
116
|
-
- Updated RuboCop configuration for new file structure
|
|
78
|
+
- Resolved all RuboCop style violations
|
|
117
79
|
|
|
118
80
|
## [4.1.0] - 2025-11-23
|
|
119
81
|
|
|
120
82
|
### Added
|
|
121
83
|
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- **Health Check Rate Limiting** - Prevents abuse of health check endpoint
|
|
129
|
-
- Limits uncached health checks to once every 5 seconds per process
|
|
130
|
-
- Cached health checks (30s TTL) bypass rate limit
|
|
131
|
-
- Returns helpful error message with wait time when rate limit exceeded
|
|
132
|
-
- Thread-safe implementation with mutex synchronization
|
|
133
|
-
|
|
134
|
-
- **Consumer Reconnection Backoff** - Exponential backoff for consumer recovery
|
|
135
|
-
- Starts at 0.1s and doubles with each retry up to 30s maximum
|
|
136
|
-
- Resets counter on successful reconnection
|
|
137
|
-
- Logs detailed reconnection attempts with backoff timing
|
|
138
|
-
- Prevents excessive NATS API calls during connection issues
|
|
139
|
-
|
|
140
|
-
- **OverlapGuard Performance Cache** - 60-second TTL cache for stream metadata
|
|
141
|
-
- Reduces N+1 API calls when checking stream overlaps
|
|
142
|
-
- Thread-safe cache implementation with mutex
|
|
143
|
-
- Falls back to cached data on fetch errors
|
|
144
|
-
- Includes `clear_cache!` method for testing
|
|
145
|
-
|
|
146
|
-
- **Consumer Memory Monitoring** - Health checks for long-running consumers
|
|
147
|
-
- Logs health status every 10 minutes (iterations, memory, uptime)
|
|
148
|
-
- Warns when memory usage exceeds 1GB
|
|
149
|
-
- Suggests garbage collection when heap grows large (>100k live objects)
|
|
150
|
-
- Cross-platform memory monitoring (Linux/macOS)
|
|
151
|
-
|
|
152
|
-
- **Production Deployment Guide** - Comprehensive documentation in docs/PRODUCTION.md
|
|
153
|
-
- Database connection pool sizing guidelines
|
|
154
|
-
- NATS HA configuration examples
|
|
155
|
-
- Consumer tuning recommendations
|
|
156
|
-
- Monitoring and alerting best practices
|
|
157
|
-
- Kubernetes deployment examples with health probes
|
|
158
|
-
- Security hardening recommendations
|
|
159
|
-
- Performance optimization techniques
|
|
84
|
+
- Enhanced subject validation to prevent injection attacks
|
|
85
|
+
- Health check rate limiting (1 uncached request per 5 seconds)
|
|
86
|
+
- Exponential backoff for consumer reconnection (0.1s to 30s)
|
|
87
|
+
- 60-second TTL cache for OverlapGuard stream metadata
|
|
88
|
+
- Consumer memory monitoring with automatic health logging
|
|
89
|
+
- Production deployment guide in `docs/PRODUCTION.md`
|
|
160
90
|
|
|
161
91
|
### Changed
|
|
162
92
|
|
|
163
|
-
-
|
|
164
|
-
- `JetstreamBridge.health_check(skip_cache: true)` forces fresh check
|
|
165
|
-
- Default behavior unchanged (uses 30s cache)
|
|
166
|
-
- Rate limited when `skip_cache` is true
|
|
93
|
+
- Added `skip_cache` parameter to health check API
|
|
167
94
|
|
|
168
95
|
### Fixed
|
|
169
96
|
|
|
170
|
-
-
|
|
171
|
-
- Added cache clearing in test setup to prevent interference
|
|
172
|
-
- All 1220 tests passing with 93.32% line coverage
|
|
97
|
+
- Fixed OverlapGuard test failures with proper cache clearing
|
|
173
98
|
|
|
174
99
|
## [4.0.4] - 2025-11-23
|
|
175
100
|
|
|
176
101
|
### Fixed
|
|
177
102
|
|
|
178
|
-
-
|
|
179
|
-
- Handle both object-style and hash-style access for stream_info responses
|
|
180
|
-
- Fixes "undefined method 'streams' for Hash" error during connection establishment
|
|
181
|
-
- Adds compatibility checks using `respond_to?` for config and state attributes
|
|
182
|
-
- Updated 4 files: jetstream_bridge.rb, topology/stream.rb, topology/overlap_guard.rb, debug_helper.rb
|
|
183
|
-
- Maintains backward compatibility with older nats-pure versions
|
|
103
|
+
- Fixed nats-pure 2.5.0 compatibility with hash-style stream_info responses
|
|
184
104
|
|
|
185
105
|
## [4.0.3] - 2025-11-23
|
|
186
106
|
|
|
187
107
|
### Added
|
|
188
108
|
|
|
189
|
-
-
|
|
190
|
-
|
|
191
|
-
- Verifies NATS connection established after connect
|
|
192
|
-
- Verifies JetStream availability with account info check
|
|
193
|
-
- Helpful error messages for common misconfigurations
|
|
194
|
-
- All validation errors include specific guidance for fixes
|
|
195
|
-
|
|
196
|
-
- **Connection Logging** - Detailed logging throughout connection lifecycle
|
|
197
|
-
- Debug logs for URL validation progress and verification steps
|
|
198
|
-
- Info logs for successful validation and JetStream stats (streams, consumers, memory, storage)
|
|
199
|
-
- Error logs for all validation failures with specific details
|
|
200
|
-
- Automatic credential sanitization in all log messages
|
|
201
|
-
- Human-readable resource usage formatting (bytes to KB/MB/GB)
|
|
109
|
+
- Comprehensive NATS URL validation on initialization
|
|
110
|
+
- Detailed connection lifecycle logging with credential sanitization
|
|
202
111
|
|
|
203
112
|
### Fixed
|
|
204
113
|
|
|
205
|
-
-
|
|
206
|
-
- Changed `stream_info[:exists]` to `stream_info&.fetch(:exists, false)` for proper nil handling
|
|
207
|
-
- Ensures boolean values always returned for monitoring systems
|
|
114
|
+
- Fixed health check returning `nil` instead of `false` when disconnected
|
|
208
115
|
|
|
209
116
|
### Changed
|
|
210
117
|
|
|
211
|
-
-
|
|
212
|
-
- Removed inline comments from 5 files (logging.rb, model_utils.rb, inbox_event.rb, outbox_event.rb, inbox_message.rb)
|
|
213
|
-
- Added exclusions to `.rubocop.yml` for metrics and naming rules
|
|
214
|
-
- Cleaner codebase with all style exceptions in one location
|
|
118
|
+
- Moved inline RuboCop rules to centralized `.rubocop.yml`
|
|
215
119
|
|
|
216
120
|
## [4.0.2] - 2025-11-23
|
|
217
121
|
|
|
218
122
|
### Fixed
|
|
219
123
|
|
|
220
|
-
-
|
|
221
|
-
- Skip all stream updates when retention policy differs from expected 'workqueue'
|
|
222
|
-
- Prevents "stream configuration update can not change retention policy to/from workqueue" error
|
|
223
|
-
- Logs warning when stream has mismatched retention policy but skips update
|
|
224
|
-
- Ensures compatibility with existing streams that have different retention policies
|
|
124
|
+
- Prevented retention policy change errors by skipping updates when policy differs
|
|
225
125
|
|
|
226
126
|
## [4.0.1] - 2025-11-23
|
|
227
127
|
|
|
228
128
|
### Fixed
|
|
229
129
|
|
|
230
|
-
-
|
|
231
|
-
- Installation instructions now reference version 4.0
|
|
232
|
-
- Health check example output shows correct version
|
|
233
|
-
- YARD documentation reflects current version
|
|
130
|
+
- Updated version references in documentation
|
|
234
131
|
|
|
235
132
|
## [4.0.0] - 2025-11-23
|
|
236
133
|
|
|
237
134
|
### Breaking Changes
|
|
238
135
|
|
|
239
|
-
-
|
|
240
|
-
- **Old pattern**: `{env}.sync.dlq` (shared across all apps)
|
|
241
|
-
- **New pattern**: `{env}.{app_name}.sync.dlq` (isolated per app)
|
|
242
|
-
- **Example**: `production.api.sync.dlq` instead of `production.sync.dlq`
|
|
243
|
-
|
|
244
|
-
### Benefits
|
|
245
|
-
|
|
246
|
-
- **Isolation**: Failed messages from different services don't mix
|
|
247
|
-
- **Easier Monitoring**: Track DLQ metrics per service
|
|
248
|
-
- **Simpler Debugging**: Identify which service is having issues
|
|
249
|
-
- **Independent Processing**: Each team can manage their own DLQ consumer
|
|
136
|
+
- Changed DLQ subject pattern from `{env}.sync.dlq` (shared) to `{env}.{app_name}.sync.dlq` (per-app) for better isolation and monitoring
|
|
250
137
|
|
|
251
138
|
### Migration Guide
|
|
252
139
|
|
|
253
|
-
1.
|
|
254
|
-
2.
|
|
255
|
-
3.
|
|
256
|
-
4.
|
|
140
|
+
1. Drain existing DLQ messages from `{env}.sync.dlq`
|
|
141
|
+
2. Deploy update (each app creates its own DLQ subject automatically)
|
|
142
|
+
3. Update monitoring dashboards to track per-app DLQ subjects
|
|
143
|
+
4. Update DLQ consumer configuration
|
|
257
144
|
|
|
258
|
-
###
|
|
259
|
-
|
|
260
|
-
- **Enhanced README** - Comprehensive documentation improvements
|
|
261
|
-
- Fixed consumer handler signature (single `event` parameter, not three)
|
|
262
|
-
- Added complete DLQ consumer examples with Rake task
|
|
263
|
-
- Added thread-safety documentation for Publisher
|
|
264
|
-
- Updated all subject pattern references
|
|
265
|
-
- Added DLQ monitoring examples
|
|
266
|
-
- **YARD documentation** - Professional API documentation
|
|
267
|
-
- Added `.yardopts` configuration for consistent doc generation
|
|
268
|
-
- 60%+ documentation coverage across public APIs
|
|
269
|
-
- Configured RubyDoc.info integration
|
|
270
|
-
- Added Rake tasks for generating docs (`rake yard`)
|
|
271
|
-
|
|
272
|
-
### Code Quality
|
|
145
|
+
### Changed
|
|
273
146
|
|
|
274
|
-
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
- Added clear comments for non-correctable patterns
|
|
147
|
+
- Enhanced README with corrected handler signatures and DLQ examples
|
|
148
|
+
- Added YARD documentation with 60%+ API coverage
|
|
149
|
+
- Achieved RuboCop compliance across entire codebase
|
|
278
150
|
|
|
279
151
|
## [3.0.0] - 2025-11-23
|
|
280
152
|
|
|
281
153
|
### Added
|
|
282
154
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
- Automatic route injection into `config/routes.rb`
|
|
293
|
-
- Returns appropriate HTTP status codes (200/503)
|
|
294
|
-
- **Auto-reconnection** - Automatic recovery from connection failures
|
|
295
|
-
- Exponential backoff retry strategy
|
|
296
|
-
- Configurable retry limits and delays
|
|
297
|
-
- Connection state tracking with timestamps
|
|
298
|
-
- **Connection factory** - Centralized connection management
|
|
299
|
-
- Singleton pattern for connection handling
|
|
300
|
-
- Thread-safe connection access
|
|
301
|
-
- Public `connected?` and `connected_at` accessors
|
|
302
|
-
|
|
303
|
-
#### Error Handling
|
|
304
|
-
|
|
305
|
-
- **Comprehensive error hierarchy** - Well-organized exception classes
|
|
306
|
-
- `ConfigurationError` - Base for configuration issues
|
|
307
|
-
- `ConnectionError` - Base for connection problems
|
|
308
|
-
- `PublishError` - Base for publishing failures
|
|
309
|
-
- `ConsumerError` - Base for consumption issues
|
|
310
|
-
- `TopologyError` - Base for stream/subject topology errors
|
|
311
|
-
- `DlqError` - Base for dead-letter queue operations
|
|
312
|
-
- All inherit from `JetstreamBridge::Error`
|
|
313
|
-
|
|
314
|
-
#### Developer Experience
|
|
315
|
-
|
|
316
|
-
- **Debug helper** - Comprehensive debugging utility via `JetstreamBridge::DebugHelper`
|
|
317
|
-
- Configuration dump
|
|
318
|
-
- Connection status
|
|
319
|
-
- Stream information
|
|
320
|
-
- Subject validation
|
|
321
|
-
- Model availability checks
|
|
322
|
-
- **Rake tasks** - CLI tools for operations
|
|
323
|
-
- `rake jetstream_bridge:health` - Check health and connection status
|
|
324
|
-
- `rake jetstream_bridge:validate` - Validate configuration
|
|
325
|
-
- `rake jetstream_bridge:test_connection` - Test NATS connection
|
|
326
|
-
- `rake jetstream_bridge:debug` - Show comprehensive debug information
|
|
327
|
-
- **Value objects** - Type-safe domain models
|
|
328
|
-
- `EventEnvelope` - Structured event representation
|
|
329
|
-
- `Subject` - Subject pattern validation and parsing
|
|
330
|
-
|
|
331
|
-
#### Testing & Quality
|
|
332
|
-
|
|
333
|
-
- **Comprehensive test suite** - 248 RSpec tests covering all core functionality
|
|
334
|
-
- Configuration validation specs
|
|
335
|
-
- Connection factory specs with edge cases (48 new tests added)
|
|
336
|
-
- Server URL normalization (single, comma-separated, arrays, whitespace)
|
|
337
|
-
- Authentication options (user, pass, token)
|
|
338
|
-
- NATS URL validation (nil, empty, whitespace-only)
|
|
339
|
-
- JetStream context creation and nc accessor
|
|
340
|
-
- Event envelope specs with full coverage (18 new tests added)
|
|
341
|
-
- Initialization edge cases (trace ID, Time objects, resource ID extraction)
|
|
342
|
-
- Hash serialization and deserialization
|
|
343
|
-
- Deep immutability validation
|
|
344
|
-
- Equality and hashing behavior
|
|
345
|
-
- Error handling for invalid timestamps
|
|
346
|
-
- Retry strategy specs
|
|
347
|
-
- Model specs
|
|
348
|
-
- Error hierarchy specs
|
|
349
|
-
- **Subject validation** - Prevents NATS wildcards in configuration
|
|
350
|
-
- Validates `env`, `app_name`, and `destination_app` don't contain `.`, `*`, or `>`
|
|
351
|
-
- Clear error messages for invalid subjects
|
|
352
|
-
- **Bug fixes in implementation** - Fixed `EventEnvelope.from_h` to properly handle deserialization
|
|
353
|
-
- Removed invalid `schema_version` parameter
|
|
354
|
-
- Added missing `resource_id` parameter
|
|
155
|
+
- Comprehensive health check API and Rails generator for monitoring endpoints
|
|
156
|
+
- Auto-reconnection with exponential backoff and connection state tracking
|
|
157
|
+
- Centralized connection factory with thread-safe access
|
|
158
|
+
- Well-organized error hierarchy with specific exception classes
|
|
159
|
+
- Debug helper utility with configuration and connection diagnostics
|
|
160
|
+
- Rake tasks for health checks, validation, and connection testing
|
|
161
|
+
- Type-safe value objects (EventEnvelope, Subject)
|
|
162
|
+
- Comprehensive test suite with 248+ RSpec tests
|
|
163
|
+
- Subject validation to prevent NATS wildcards
|
|
355
164
|
|
|
356
165
|
### Changed
|
|
357
166
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
-
|
|
372
|
-
- Respects `config.logger` setting
|
|
373
|
-
- Falls back to `Rails.logger` in Rails apps
|
|
374
|
-
- Uses `STDOUT` logger otherwise
|
|
375
|
-
|
|
376
|
-
#### Bug Fixes
|
|
377
|
-
|
|
378
|
-
- **Fixed duration parsing** - Correct integer conversion for duration strings
|
|
379
|
-
- Handles edge cases properly
|
|
380
|
-
- Added comprehensive tests
|
|
381
|
-
- **Fixed subject format** - Corrected DLQ subject pattern
|
|
382
|
-
- Changed from `{env}.data.sync.dlq` to `{env}.sync.dlq`
|
|
383
|
-
- Updated all documentation
|
|
384
|
-
- **Repository improvements**
|
|
385
|
-
- Transaction safety for all database operations
|
|
386
|
-
- Pessimistic locking for outbox operations
|
|
387
|
-
- Race condition protection
|
|
388
|
-
- Better error handling and logging
|
|
167
|
+
- Consolidated configuration with streamlined Config class
|
|
168
|
+
- Enhanced generator templates with better documentation
|
|
169
|
+
- Simplified consumer initialization with sensible defaults
|
|
170
|
+
- Improved logging with configurable logger and fallbacks
|
|
171
|
+
- Switched to Oj for JSON handling performance
|
|
172
|
+
- Enhanced topology management with better overlap detection
|
|
173
|
+
- Updated README with generators, rake tasks, and operations guide
|
|
174
|
+
|
|
175
|
+
### Fixed
|
|
176
|
+
|
|
177
|
+
- Fixed duration parsing for edge cases
|
|
178
|
+
- Corrected DLQ subject pattern
|
|
179
|
+
- Improved repository transaction safety and locking
|
|
180
|
+
- Fixed EventEnvelope deserialization
|
|
389
181
|
|
|
390
182
|
### Refactored
|
|
391
183
|
|
|
392
|
-
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
- Clearer separation of concerns
|
|
396
|
-
- **Model handling** - Streamlined inbox/outbox models
|
|
397
|
-
- Graceful column detection without connection boot
|
|
398
|
-
- Better validation guards
|
|
399
|
-
- Simplified attribute handling
|
|
400
|
-
- **JSON handling** - Switched to Oj for performance
|
|
401
|
-
- Faster JSON parsing/serialization
|
|
402
|
-
- Consistent JSON handling across the gem
|
|
403
|
-
- **Topology management** - Enhanced stream and subject handling
|
|
404
|
-
- Improved overlap detection
|
|
405
|
-
- Better error messages
|
|
406
|
-
- More robust subject matching
|
|
407
|
-
|
|
408
|
-
### Documentation Updates
|
|
409
|
-
|
|
410
|
-
- **Updated README** - Comprehensive documentation updates
|
|
411
|
-
- Added section for Rails generators and rake tasks
|
|
412
|
-
- Documented all new health check features
|
|
413
|
-
- Fixed incorrect subject patterns
|
|
414
|
-
- Added operations guide
|
|
415
|
-
- Improved getting started section
|
|
416
|
-
- **Enhanced code comments** - Better inline documentation
|
|
417
|
-
- YARD-style documentation for public APIs
|
|
418
|
-
- Clear explanations of complex logic
|
|
419
|
-
- Usage examples in comments
|
|
420
|
-
- **Generator improvements** - Better user guidance
|
|
421
|
-
- Clear success messages
|
|
422
|
-
- Usage instructions after generation
|
|
423
|
-
- Example configurations
|
|
424
|
-
|
|
425
|
-
### Internal
|
|
426
|
-
|
|
427
|
-
- **Removed deprecated code**
|
|
428
|
-
- Cleaned up unused classes and methods
|
|
429
|
-
- Removed `BackoffStrategy` (consolidated into retry strategy)
|
|
430
|
-
- Removed `ConsumerConfig` (merged into main config)
|
|
431
|
-
- Removed `MessageContext` (functionality integrated)
|
|
184
|
+
- Consolidated consumer architecture
|
|
185
|
+
- Streamlined inbox/outbox model handling
|
|
186
|
+
- Removed deprecated code (BackoffStrategy, ConsumerConfig, MessageContext)
|
|
432
187
|
|
|
433
188
|
## [2.10.0] and earlier
|
|
434
189
|
|
data/README.md
CHANGED
|
@@ -47,17 +47,13 @@ bin/rails db:migrate
|
|
|
47
47
|
# config/initializers/jetstream_bridge.rb
|
|
48
48
|
JetstreamBridge.configure do |config|
|
|
49
49
|
config.nats_urls = ENV.fetch("NATS_URLS", "nats://localhost:4222")
|
|
50
|
-
config.env = ENV.fetch("RAILS_ENV", "development")
|
|
51
50
|
config.app_name = "my_app"
|
|
52
51
|
config.destination_app = "worker_app"
|
|
52
|
+
config.stream_name = "my_app-jetstream-bridge-stream"
|
|
53
53
|
config.use_outbox = true
|
|
54
54
|
config.use_inbox = true
|
|
55
55
|
config.use_dlq = true
|
|
56
56
|
end
|
|
57
|
-
|
|
58
|
-
# Note: configure only sets options; it does not connect. In Rails the Railtie
|
|
59
|
-
# starts the bridge after initialization. In non-Rails apps call
|
|
60
|
-
# `JetstreamBridge.startup!` (or rely on auto-connect on first publish/subscribe).
|
|
61
57
|
```
|
|
62
58
|
|
|
63
59
|
Publish:
|
data/docs/GETTING_STARTED.md
CHANGED
|
@@ -39,9 +39,9 @@ Generators create:
|
|
|
39
39
|
# config/initializers/jetstream_bridge.rb
|
|
40
40
|
JetstreamBridge.configure do |config|
|
|
41
41
|
config.nats_urls = ENV.fetch("NATS_URLS", "nats://localhost:4222")
|
|
42
|
-
config.env = ENV.fetch("RAILS_ENV", "development")
|
|
43
42
|
config.app_name = "my_app"
|
|
44
43
|
config.destination_app = ENV.fetch("DESTINATION_APP")
|
|
44
|
+
config.stream_name = "my_app-jetstream-bridge-stream" # required
|
|
45
45
|
|
|
46
46
|
config.use_outbox = true # transactional publish
|
|
47
47
|
config.use_inbox = true # idempotent consume
|
|
@@ -51,15 +51,19 @@ JetstreamBridge.configure do |config|
|
|
|
51
51
|
config.max_deliver = 5
|
|
52
52
|
config.ack_wait = "30s"
|
|
53
53
|
config.backoff = %w[1s 5s 15s 30s 60s]
|
|
54
|
-
end
|
|
55
54
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
#
|
|
55
|
+
# Optional: Custom inbox prefix if NATS account restricts _INBOX.>
|
|
56
|
+
# config.inbox_prefix = "$RPC"
|
|
57
|
+
|
|
58
|
+
# Optional: Pre-provisioned stream/consumer names
|
|
59
|
+
# config.durable_name = "my-durable"
|
|
60
|
+
|
|
61
|
+
# Optional: Disable JetStream management APIs (requires pre-provisioning)
|
|
62
|
+
# config.disable_js_api = false
|
|
63
|
+
end
|
|
60
64
|
```
|
|
61
65
|
|
|
62
|
-
Rails
|
|
66
|
+
Rails starts JetStream Bridge automatically after initialization. For non-Rails apps, call `JetstreamBridge.connect!` or rely on auto-connect on first publish/subscribe.
|
|
63
67
|
|
|
64
68
|
## Publish
|
|
65
69
|
|