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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe94130ab86adb28c2623f20b6ad744cb51550fa2130750cbdcb30a0949e002e
4
- data.tar.gz: 97e0957974e440f4ecb5ae7b129920da0e60bc727a07c03764b67035ebcdacd6
3
+ metadata.gz: 7f8e7cce25c596230a2d068e4f3aca0bfdc7d5156c9fb724e34f094e97d8909f
4
+ data.tar.gz: 21c66a2c19cf8e6d49017efd53dd53f7d1ae2654bac2b0df3e9f6b8d137e11e9
5
5
  SHA512:
6
- metadata.gz: be18e0b5fff0b38a5605d86ac870a73e1e471be0d8aae4eb122dd4f4a7084399156fc4a5a2249344d46eea01b385cdf51476c42ed2e782b8b75997ef200eb2c6
7
- data.tar.gz: 5063a30a0146f6dc6acafded1a86ef12e7aab41edb13f99c5c3366c507a4a277f0c92ef957d2ce73178ae8ef48aae5320190f748890f0cff160220196c1ddb8f
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
- start = Time.now
72
- nc.rtt
73
- ((Time.now - start) * 1000).round(2)
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)
@@ -133,7 +133,7 @@ module JetstreamBridge
133
133
  end
134
134
 
135
135
  def rake_task?
136
- !!defined?(::Rake) || File.basename($PROGRAM_NAME) == 'rake'
136
+ File.basename($PROGRAM_NAME) == 'rake'
137
137
  end
138
138
 
139
139
  def active_logger
@@ -4,5 +4,5 @@
4
4
  #
5
5
  # Version constant for the gem.
6
6
  module JetstreamBridge
7
- VERSION = '4.3.0'
7
+ VERSION = '4.4.0'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jetstream_bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Attara