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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -337
  3. data/README.md +1 -5
  4. data/docs/GETTING_STARTED.md +11 -7
  5. data/docs/PRODUCTION.md +51 -11
  6. data/docs/TESTING.md +24 -35
  7. data/lib/generators/jetstream_bridge/health_check/health_check_generator.rb +1 -1
  8. data/lib/generators/jetstream_bridge/initializer/initializer_generator.rb +1 -1
  9. data/lib/generators/jetstream_bridge/initializer/templates/jetstream_bridge.rb +0 -4
  10. data/lib/generators/jetstream_bridge/install/install_generator.rb +5 -5
  11. data/lib/generators/jetstream_bridge/migrations/migrations_generator.rb +2 -2
  12. data/lib/jetstream_bridge/consumer/consumer.rb +34 -96
  13. data/lib/jetstream_bridge/consumer/health_monitor.rb +107 -0
  14. data/lib/jetstream_bridge/consumer/message_processor.rb +1 -1
  15. data/lib/jetstream_bridge/consumer/subscription_manager.rb +51 -34
  16. data/lib/jetstream_bridge/core/config.rb +153 -46
  17. data/lib/jetstream_bridge/core/connection_manager.rb +513 -0
  18. data/lib/jetstream_bridge/core/debug_helper.rb +9 -3
  19. data/lib/jetstream_bridge/core/health_checker.rb +184 -0
  20. data/lib/jetstream_bridge/core.rb +0 -2
  21. data/lib/jetstream_bridge/facade.rb +212 -0
  22. data/lib/jetstream_bridge/publisher/event_envelope_builder.rb +110 -0
  23. data/lib/jetstream_bridge/publisher/publisher.rb +87 -117
  24. data/lib/jetstream_bridge/rails/integration.rb +8 -5
  25. data/lib/jetstream_bridge/rails/railtie.rb +4 -3
  26. data/lib/jetstream_bridge/tasks/install.rake +0 -1
  27. data/lib/jetstream_bridge/topology/topology.rb +6 -1
  28. data/lib/jetstream_bridge/version.rb +1 -1
  29. data/lib/jetstream_bridge.rb +206 -297
  30. metadata +7 -5
  31. data/lib/jetstream_bridge/core/bridge_helpers.rb +0 -109
  32. data/lib/jetstream_bridge/core/connection.rb +0 -464
  33. 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: 7f8e7cce25c596230a2d068e4f3aca0bfdc7d5156c9fb724e34f094e97d8909f
4
- data.tar.gz: 21c66a2c19cf8e6d49017efd53dd53f7d1ae2654bac2b0df3e9f6b8d137e11e9
3
+ metadata.gz: 2f7e89386a56dac571dddec4c9d5283a975a8354d17d8f953ba148d390d55652
4
+ data.tar.gz: 64d5a7ea6bfdf863ea6a24d7d922cfaca565247605860cd999d6c2a8c893f48d
5
5
  SHA512:
6
- metadata.gz: 312c184a87c6d2b70e711c666b74f2a79a4c9d9afc29faf53776f46a906eab83e6ed2103d68e9f12e09cdb8b082c078f405769eeb13630adf998f9a498f82793
7
- data.tar.gz: caeca3948e682aefb27f3de0617fba8d2558edb2c4a798ad732f16463a23a1bf586295918cb8a91cfddfef25b3b6b3df049a9ab84986b377f4da4f91080c9d67
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.4.0] - 2025-11-24
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
- - **RTT Measurement** - Enhanced NATS round-trip time measurement with fallback support
13
- - Added automatic unit normalization (seconds to milliseconds) for RTT values
14
- - Implemented fallback RTT measurement using `flush` for NATS clients without native `rtt` method
15
- - Supports both nats-pure and other NATS client implementations
16
- - Better compatibility across different NATS client versions
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
- - **Rails Integration** - Improved Rake task detection reliability
19
- - Changed from `defined?(::Rake)` check to `$PROGRAM_NAME` inspection
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
- - **Test Coverage** - Comprehensive test suite improvements
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
- - **Connection Diagnostics** - Exposed reconnection error tracking for health checks
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
- - **Connection Lifecycle** - Improved topology management during startup
44
- - `startup!` now explicitly ensures topology is created during initialization
45
- - `connect_and_ensure_stream!` properly ensures topology after connecting
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
- - **Test Coverage** - Added missing test scenarios
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
- - **Modular Code Organization** - Restructured codebase with dedicated modules
73
- - New `JetstreamBridge::Core` module for core utilities (connection, logging, model utils, helpers)
74
- - New `JetstreamBridge::Rails` module for Rails-specific integration
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
- - **Rails Integration** - Reorganized Rails-specific code
94
- - Moved from single `lib/jetstream_bridge/railtie.rb` to dedicated `lib/jetstream_bridge/rails/` directory
95
- - `JetstreamBridge::Rails::Railtie` - Rails lifecycle integration
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
- - **Code Quality** - Resolved all RuboCop style violations
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
- - **Enhanced Subject Validation** - Strengthened subject component validation for security
123
- - Validates against control characters, null bytes, tabs, and excessive spaces
124
- - Enforces maximum subject component length of 255 characters
125
- - Prevents injection attacks via malformed subject components
126
- - Provides clear error messages with invalid character details
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
- - **Health Check API** - Added optional `skip_cache` parameter
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
- - **Test Suite** - Fixed test failures in OverlapGuard specs
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
- - **NATS Compatibility** - Fix connection failure with nats-pure 2.5.0
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
- - **Connection Validation** - Comprehensive NATS URL validation on initialization
190
- - Validates URL format, scheme (nats/nats+tls), host presence, and port range (1-65535)
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
- - **Health Check** - Fixed `healthy` field returning `nil` instead of `false` when disconnected
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
- - **Code Organization** - Moved all inline RuboCop rules to centralized `.rubocop.yml`
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
- - **Stream Updates** - Prevent retention policy change errors (NATS error 10052)
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
- - **Documentation** - Updated version references in README and YARD documentation
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
- - **Per-app Dead Letter Queue (DLQ)** - DLQ subject pattern changed for better isolation
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. **Drain existing DLQ**: Process or archive messages from the old shared DLQ (`{env}.sync.dlq`)
254
- 2. **Deploy update**: Each app will automatically create its own DLQ subject on next deployment
255
- 3. **Update monitoring**: Adjust dashboards to track per-app DLQ subjects (`{env}.{app_name}.sync.dlq`)
256
- 4. **Update DLQ consumers**: Update DLQ consumer configuration to use app-specific subjects
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
- ### Documentation
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
- - **RuboCop compliance** - Zero offenses across entire codebase
275
- - Configured appropriate exclusions for test files and acceptable patterns
276
- - Fixed all auto-correctable style violations
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
- #### Production-Ready Features
284
-
285
- - **Health checks** - Comprehensive health check API via `JetstreamBridge.health_check`
286
- - NATS connection status monitoring
287
- - Stream existence and subject verification
288
- - Configuration validation
289
- - Returns structured health data for monitoring systems
290
- - **Health check generator** - Rails generator for creating health check endpoints
291
- - `rails g jetstream_bridge:health_check` creates controller and route
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
- #### Architecture Improvements
359
-
360
- - **Consolidated configuration** - Streamlined `Config` class
361
- - Removed redundant configuration classes
362
- - Centralized validation logic
363
- - Better default values
364
- - **Enhanced generator templates** - Improved initializer template
365
- - Better documentation and comments
366
- - Organized sections (Connection, Consumer, Reliability, Models, Logging)
367
- - Clear indication of required vs optional settings
368
- - **Simplified consumer initialization** - Cleaner API
369
- - Sensible defaults for `durable_name` and `batch_size`
370
- - Removed unnecessary configuration classes
371
- - **Better logging** - Configurable logger with sensible defaults
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
- - **Consumer architecture** - Consolidated consumer support classes
393
- - Merged related functionality
394
- - Reduced file count
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:
@@ -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
- # Note: `configure` only sets options; it does not connect. Rails will start
57
- # JetstreamBridge after initialization via the Railtie. For non-Rails or custom
58
- # boot flows, call `JetstreamBridge.startup!` (or rely on auto-connect on first
59
- # publish/subscribe).
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 autostart runs after initialization (including in console). You can opt out for rake tasks or other tooling with `config.lazy_connect = true` or `JETSTREAM_BRIDGE_DISABLE_AUTOSTART=1`; it will then connect on first publish/subscribe.
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