jetstream_bridge 4.3.0 → 4.4.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 +24 -0
- data/lib/jetstream_bridge/core/bridge_helpers.rb +23 -4
- data/lib/jetstream_bridge/rails/integration.rb +1 -1
- data/lib/jetstream_bridge/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f8e7cce25c596230a2d068e4f3aca0bfdc7d5156c9fb724e34f094e97d8909f
|
|
4
|
+
data.tar.gz: 21c66a2c19cf8e6d49017efd53dd53f7d1ae2654bac2b0df3e9f6b8d137e11e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 312c184a87c6d2b70e711c666b74f2a79a4c9d9afc29faf53776f46a906eab83e6ed2103d68e9f12e09cdb8b082c078f405769eeb13630adf998f9a498f82793
|
|
7
|
+
data.tar.gz: caeca3948e682aefb27f3de0617fba8d2558edb2c4a798ad732f16463a23a1bf586295918cb8a91cfddfef25b3b6b3df049a9ab84986b377f4da4f91080c9d67
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ 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
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
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
|
|
17
|
+
|
|
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
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
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
|
|
31
|
+
|
|
8
32
|
## [4.3.0] - 2025-11-24
|
|
9
33
|
|
|
10
34
|
### Added
|
|
@@ -66,11 +66,20 @@ module JetstreamBridge
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def measure_nats_rtt
|
|
69
|
-
# Measure round-trip time using NATS RTT method
|
|
70
69
|
nc = Connection.nc
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(
|
|
70
|
+
return nil unless nc
|
|
71
|
+
|
|
72
|
+
# Prefer native RTT API when available (e.g., new NATS clients)
|
|
73
|
+
if nc.respond_to?(:rtt)
|
|
74
|
+
rtt_value = normalize_ms(nc.rtt)
|
|
75
|
+
return rtt_value if rtt_value
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Fallback for clients without #rtt (nats-pure): measure ping/pong via flush
|
|
79
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
80
|
+
nc.flush(1)
|
|
81
|
+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
82
|
+
normalize_ms(duration)
|
|
74
83
|
rescue StandardError => e
|
|
75
84
|
Logging.warn(
|
|
76
85
|
"Failed to measure NATS RTT: #{e.class} #{e.message}",
|
|
@@ -79,6 +88,16 @@ module JetstreamBridge
|
|
|
79
88
|
nil
|
|
80
89
|
end
|
|
81
90
|
|
|
91
|
+
def normalize_ms(value)
|
|
92
|
+
return nil if value.nil?
|
|
93
|
+
return nil unless value.respond_to?(:to_f)
|
|
94
|
+
|
|
95
|
+
numeric = value.to_f
|
|
96
|
+
# Heuristic: sub-1 values are likely seconds; convert them to ms for reporting
|
|
97
|
+
ms = numeric < 1 ? numeric * 1000 : numeric
|
|
98
|
+
ms.round(2)
|
|
99
|
+
end
|
|
100
|
+
|
|
82
101
|
def assign_config_option!(cfg, key, val)
|
|
83
102
|
setter = :"#{key}="
|
|
84
103
|
raise ArgumentError, "Unknown configuration option: #{key}" unless cfg.respond_to?(setter)
|