jetstream_bridge 4.0.4 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +106 -0
  3. data/README.md +22 -1402
  4. data/docs/GETTING_STARTED.md +92 -0
  5. data/docs/PRODUCTION.md +503 -0
  6. data/docs/TESTING.md +414 -0
  7. data/lib/jetstream_bridge/consumer/consumer.rb +101 -5
  8. data/lib/jetstream_bridge/consumer/inbox/inbox_processor.rb +17 -3
  9. data/lib/jetstream_bridge/consumer/inbox/inbox_repository.rb +19 -7
  10. data/lib/jetstream_bridge/consumer/message_processor.rb +88 -52
  11. data/lib/jetstream_bridge/consumer/subscription_manager.rb +24 -15
  12. data/lib/jetstream_bridge/core/bridge_helpers.rb +85 -0
  13. data/lib/jetstream_bridge/core/config.rb +27 -4
  14. data/lib/jetstream_bridge/core/connection.rb +162 -13
  15. data/lib/jetstream_bridge/core.rb +8 -0
  16. data/lib/jetstream_bridge/models/inbox_event.rb +13 -7
  17. data/lib/jetstream_bridge/models/outbox_event.rb +2 -2
  18. data/lib/jetstream_bridge/publisher/publisher.rb +10 -5
  19. data/lib/jetstream_bridge/rails/integration.rb +153 -0
  20. data/lib/jetstream_bridge/rails/railtie.rb +53 -0
  21. data/lib/jetstream_bridge/rails.rb +5 -0
  22. data/lib/jetstream_bridge/tasks/install.rake +1 -1
  23. data/lib/jetstream_bridge/test_helpers/fixtures.rb +41 -0
  24. data/lib/jetstream_bridge/test_helpers/integration_helpers.rb +77 -0
  25. data/lib/jetstream_bridge/test_helpers/matchers.rb +98 -0
  26. data/lib/jetstream_bridge/test_helpers/mock_nats.rb +524 -0
  27. data/lib/jetstream_bridge/test_helpers.rb +85 -121
  28. data/lib/jetstream_bridge/topology/overlap_guard.rb +46 -0
  29. data/lib/jetstream_bridge/topology/stream.rb +7 -4
  30. data/lib/jetstream_bridge/version.rb +1 -1
  31. data/lib/jetstream_bridge.rb +138 -63
  32. metadata +32 -12
  33. data/lib/jetstream_bridge/railtie.rb +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2af28b3492eb97a04b9337390f71f90786321baf7c50f3f49de3a2cbe1b5c3
4
- data.tar.gz: 3746cb676e9739a087c295488d85b51a6acec82c4ffca81027726cf33a9ada53
3
+ metadata.gz: 40f09bd9d0341dd242cbd29f7eaa4c848d180886f4e11c76ca97fca5f312e8d9
4
+ data.tar.gz: e2d8d22a90787f7824953c4d869ecc57e8eaebcd6948ed18a45033684dc45ce5
5
5
  SHA512:
6
- metadata.gz: 91cff40e1f076eaee83bf937d10cbbcaaaf0e311fabb347e3ae757d7e7bd0645bcea338cd222cbfcb9d42c37deefd88076d618af2185572ca4cdeb4fa85dea27
7
- data.tar.gz: 5fc680881fb91c550b8f6561babfd2227a3a9e263d3c07f1bd89a0de61fd835a8bf74b0731603384a16f078b401f22afbdbf31e94d62bac88ed1473f8c0aa15b
6
+ metadata.gz: 0bdc25b39ba3fdd08c70795f2db348c2155951af8a88d5acbca55eac6a36850ffaa4b9cc103e8a9774080aa798ba871792a7d9604f79ef94734164b7b9bbc9f3
7
+ data.tar.gz: 54f528ac27f9031adbc794e4d31d7ba0d88f241dec379e063592b80a51a67cc0f3a9bb9af640a28d7d810de4686b17093ca79b3576ed48aa0198639f42fb1782
data/CHANGELOG.md CHANGED
@@ -5,6 +5,112 @@ 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.2.0] - 2025-11-24
9
+
10
+ ### Added
11
+
12
+ - **Modular Code Organization** - Restructured codebase with dedicated modules
13
+ - New `JetstreamBridge::Core` module for core utilities (connection, logging, model utils, helpers)
14
+ - New `JetstreamBridge::Rails` module for Rails-specific integration
15
+ - Improved separation of concerns and code discoverability
16
+ - Better namespace organization for future extensibility
17
+
18
+ - **Enhanced Test Helpers** - Comprehensive testing utilities split into focused modules
19
+ - `JetstreamBridge::TestHelpers::Fixtures` - Convenient fixture generation for events and messages
20
+ - `JetstreamBridge::TestHelpers::IntegrationHelpers` - Full NATS message simulation for integration tests
21
+ - `JetstreamBridge::TestHelpers::Matchers` - RSpec matchers for event publishing assertions
22
+ - Improved test doubles with realistic NATS message structure
23
+ - Better support for testing event-driven Rails applications
24
+
25
+ - **Getting Started Guide** - New comprehensive guide in `docs/GETTING_STARTED.md`
26
+ - Quick installation and setup instructions
27
+ - Publishing and consuming examples
28
+ - Rails integration patterns
29
+ - Links to advanced documentation
30
+
31
+ ### Changed
32
+
33
+ - **Rails Integration** - Reorganized Rails-specific code
34
+ - Moved from single `lib/jetstream_bridge/railtie.rb` to dedicated `lib/jetstream_bridge/rails/` directory
35
+ - `JetstreamBridge::Rails::Railtie` - Rails lifecycle integration
36
+ - `JetstreamBridge::Rails::Integration` - Autostart logic and Rails environment detection
37
+ - Cleaner separation between gem core and Rails integration
38
+
39
+ - **Documentation** - Restructured README for clarity
40
+ - Condensed README focusing on quick start and highlights
41
+ - Moved detailed guides to dedicated docs directory
42
+ - Improved navigation with links to specialized documentation
43
+ - More concise examples and clearer feature descriptions
44
+
45
+ - **Gemspec** - Enhanced package configuration
46
+ - Added `docs/**/*.md` to distributed files
47
+ - Added `extra_rdoc_files` for better documentation
48
+ - Updated description to emphasize production-readiness
49
+
50
+ ### Fixed
51
+
52
+ - **Code Quality** - Resolved all RuboCop style violations
53
+ - Fixed string literal consistency issues
54
+ - Improved code formatting and indentation
55
+ - Reduced complexity in conditional assignments
56
+ - Updated RuboCop configuration for new file structure
57
+
58
+ ## [4.1.0] - 2025-11-23
59
+
60
+ ### Added
61
+
62
+ - **Enhanced Subject Validation** - Strengthened subject component validation for security
63
+ - Validates against control characters, null bytes, tabs, and excessive spaces
64
+ - Enforces maximum subject component length of 255 characters
65
+ - Prevents injection attacks via malformed subject components
66
+ - Provides clear error messages with invalid character details
67
+
68
+ - **Health Check Rate Limiting** - Prevents abuse of health check endpoint
69
+ - Limits uncached health checks to once every 5 seconds per process
70
+ - Cached health checks (30s TTL) bypass rate limit
71
+ - Returns helpful error message with wait time when rate limit exceeded
72
+ - Thread-safe implementation with mutex synchronization
73
+
74
+ - **Consumer Reconnection Backoff** - Exponential backoff for consumer recovery
75
+ - Starts at 0.1s and doubles with each retry up to 30s maximum
76
+ - Resets counter on successful reconnection
77
+ - Logs detailed reconnection attempts with backoff timing
78
+ - Prevents excessive NATS API calls during connection issues
79
+
80
+ - **OverlapGuard Performance Cache** - 60-second TTL cache for stream metadata
81
+ - Reduces N+1 API calls when checking stream overlaps
82
+ - Thread-safe cache implementation with mutex
83
+ - Falls back to cached data on fetch errors
84
+ - Includes `clear_cache!` method for testing
85
+
86
+ - **Consumer Memory Monitoring** - Health checks for long-running consumers
87
+ - Logs health status every 10 minutes (iterations, memory, uptime)
88
+ - Warns when memory usage exceeds 1GB
89
+ - Suggests garbage collection when heap grows large (>100k live objects)
90
+ - Cross-platform memory monitoring (Linux/macOS)
91
+
92
+ - **Production Deployment Guide** - Comprehensive documentation in docs/PRODUCTION.md
93
+ - Database connection pool sizing guidelines
94
+ - NATS HA configuration examples
95
+ - Consumer tuning recommendations
96
+ - Monitoring and alerting best practices
97
+ - Kubernetes deployment examples with health probes
98
+ - Security hardening recommendations
99
+ - Performance optimization techniques
100
+
101
+ ### Changed
102
+
103
+ - **Health Check API** - Added optional `skip_cache` parameter
104
+ - `JetstreamBridge.health_check(skip_cache: true)` forces fresh check
105
+ - Default behavior unchanged (uses 30s cache)
106
+ - Rate limited when `skip_cache` is true
107
+
108
+ ### Fixed
109
+
110
+ - **Test Suite** - Fixed test failures in OverlapGuard specs
111
+ - Added cache clearing in test setup to prevent interference
112
+ - All 1220 tests passing with 93.32% line coverage
113
+
8
114
  ## [4.0.4] - 2025-11-23
9
115
 
10
116
  ### Fixed