protobuf-nats 0.13.0.pre5 → 0.13.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: bac03c214ceddc05b8ad2ac60e1db25f4179156a78a437f6338f9b1c3404dc8c
4
- data.tar.gz: d26d42acfd6b9804093a368ebb08ea41df22896fa67f1d2e79f767c6f9aa7f00
3
+ metadata.gz: dd9d0e1d6f565a66e972312fa19398f5b027c426b363672b5aa96b5a61f00595
4
+ data.tar.gz: c253885854d9bafcd5e714f8f1ff2afdb1193758d394f42c91ebf58f70865bd6
5
5
  SHA512:
6
- metadata.gz: b8992b0220a24d05c0c1f0e67f816ea06865817a8ba0d18dcab0ba2ac36a4b561d69a144e97a7ccf3362bd33f6c4ac9b5458777aec85d2846720f71645f6952f
7
- data.tar.gz: ef9d92af39b7a59c6f7c14a47ccaada1807fcca53e3f54cbf044ff264d73b698aeaad31d51e07ad731ac865aacfb901ef498a7d63cc678d91f615ab2859e7662
6
+ metadata.gz: c6415db921943a0c61e3c310aea1a67f50fc955dfe03512d8709aeb3ae242228d8da78ce60df8158e9e7ba1b8d56cb8d59512e265a27e8f106d9fcf85fdf2c1c
7
+ data.tar.gz: ed7ff5492e9dce9a7c15aaf30885c2fa0e50533186e2c48a662eed6f80ae4db5a485a5469d3707b221956f02d05b68843273a23280cc7c9209217bca66f03c7a
data/CHANGELOG.md CHANGED
@@ -1,7 +1,24 @@
1
1
  ## Changelog
2
2
 
3
- ### 0.13.0 - WIP
4
- - Removed JNats (`nats-pure` is fast enough for JRuby and CRuby parallel work)
5
- - Added ResponseMuxer (similar to Golang)
6
- - Added instrumentation when encountering unexpected messages.
3
+ ### 0.13.0
4
+ This is a large overhaul of the client and server internals.
5
+
6
+ #### Highlights
7
+ - Removed JNats / the forked java-nats client. `nats-pure` is now used on both JRuby and CRuby (it is fast enough for parallel work), so there is a single NATS client implementation (`NATS::IO::Client`).
8
+ - Added the `ResponseMuxer`: a single wildcard subscription multiplexes all client responses (similar to the Golang client) instead of one subscription per request. This replaces the previous per-request subscribe/unsubscribe cycle and significantly reduces subscription churn.
9
+ - Added the `SuperSubscriptionManager` on the server for managing RPC endpoint subscriptions.
10
+ - Switched to `concurrent-ruby` primitives for lock-free response delivery (`Concurrent::Map`) and performance gains.
11
+ - Switched request tokens to UUIDv7 (via the `uuid7` gem, see `UUIDv7Helper`) for time-ordered, more robust request correlation.
12
+ - Added instrumentation/logging when encountering unexpected messages.
13
+ - More robust periodic cleanup, locking, restart handling, and error handling in the client and server.
14
+
15
+ #### New environment variables
16
+ - `PB_NATS_RESPONSE_MUXER_DISPATCHERS` - Number of dispatcher threads draining the shared response subscription. Defaults to `Concurrent.processor_count` on JRuby (true parallelism) and `1` on CRuby (the GVL makes extra dispatchers pointless). Minimum of 1.
17
+
18
+ #### Dependencies / requirements
19
+ - Now requires Ruby `>= 3.1.0`.
20
+ - Bumped `nats-pure` to `~> 2` (from `~> 0.3`).
21
+ - Bumped `activesupport` to `>= 6.1` (from `>= 3.2`).
22
+ - Added `concurrent-ruby` (`~> 1.3.6`, pinned so `logger` is included) and `uuid7` runtime dependencies.
23
+ - Pinned `i18n` to `< 1.15.0` in the Gemfile (workaround for ruby-i18n/i18n#735).
7
24
 
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in protobuf-nats.gemspec
4
4
  gemspec
5
+
6
+ # Pin this back until this is fixed. https://github.com/ruby-i18n/i18n/issues/735
7
+ gem "i18n", "< 1.15.0"
data/README.md CHANGED
@@ -3,6 +3,11 @@ Protobuf::Nats
3
3
 
4
4
  An rpc client and server library built using the `protobuf` gem and the NATS protocol.
5
5
 
6
+ ## Requirements
7
+
8
+ - Ruby `>= 3.1.0` (CRuby or JRuby)
9
+ - A reachable [NATS](https://nats.io/) server
10
+
6
11
  ## Installation
7
12
 
8
13
  Add this line to your application's Gemfile:
@@ -49,12 +54,14 @@ used to allow JVM based servers to warm-up slowly to prevent jolts in runtime pe
49
54
 
50
55
  `PB_NATS_CLIENT_SUBSCRIPTION_POOL_SIZE` - If subscription pooling is desired for the request/response cycle then the pool size maximum should be set; the pool is lazy and therefore will only start new subscriptions as necessary (default: 0)
51
56
 
57
+ `PB_NATS_RESPONSE_MUXER_DISPATCHERS` - Number of dispatcher threads draining the shared response subscription (see [ResponseMuxer](#how-it-works)). Defaults to `Concurrent.processor_count` on JRuby (true parallelism) and `1` on CRuby (the GVL makes extra dispatchers pointless). Minimum of 1.
58
+
52
59
  `PROTOBUF_NATS_CONFIG_PATH` - Custom path to the config yaml (default: "config/protobuf_nats.yml").
53
60
 
54
61
  ### YAML Config
55
62
 
56
- The client and server are configured via environment variables defined in the `pure-ruby-nats` gem. However, there are a
57
- few params which cannot be set: `servers`, `uses_tls`, `subscription_key_replacements`, and `connect_timeout`, so those my be defined in a yml file.
63
+ The client and server are configured via environment variables defined in the `nats-pure` gem. However, there are a
64
+ few params which cannot be set: `servers`, `uses_tls`, `subscription_key_replacements`, and `connect_timeout`, so those must be defined in a yml file.
58
65
 
59
66
  The library will automatically look for a file with a relative path of `config/protobuf_nats.yml`, but you may override
60
67
  this by specifying a different file via the `PROTOBUF_NATS_CONFIG_PATH` env variable.
@@ -148,13 +155,19 @@ And we can see the message was sent to the server and the server replied with a
148
155
  If we were to add another service endpoint called `search` to the `UserService` but fail to define an instance method
149
156
  `search`, then `protobuf-nats` will not subscribe to that route.
150
157
 
151
- ## Future Improvements (locked behind ruby version)
152
- - Migrate to native `Random.new.uuid_v7`
153
- ```ruby
154
- @prng_lock.synchronize { @prng.uuid_v7(extra_timestamp_bits: 12) }
155
- ```
156
- - Change ResponseMuxer to use `.pop()` with a timeout.
158
+ ## How it works
159
+
160
+ `protobuf-nats` uses a single NATS client implementation (`NATS::IO::Client` from `nats-pure`) on both CRuby and JRuby.
157
161
 
162
+ - **ResponseMuxer** (`lib/protobuf/nats/response_muxer.rb`) — the client uses a single wildcard subscription to multiplex
163
+ all RPC responses (similar to the Golang NATS client) instead of subscribing/unsubscribing per request. One or more
164
+ dispatcher threads drain the shared subscription and route each reply to the waiting caller via a `Concurrent::Map`,
165
+ keyed by a UUIDv7 request token. Tune the dispatcher count with `PB_NATS_RESPONSE_MUXER_DISPATCHERS`.
166
+ - **SuperSubscriptionManager** (`lib/protobuf/nats/super_subscription_manager.rb`) — the server manages the lifecycle of
167
+ RPC endpoint subscriptions, including slow start, pausing, and resubscription.
168
+
169
+ ## Future Improvements (locked behind ruby version)
170
+ - Migrate from the `uuid7` gem to native `Random#uuid_v7` once the minimum Ruby version supports it (see `UUIDv7Helper`).
158
171
 
159
172
  ## Development
160
173
 
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module Nats
3
- VERSION = "0.13.0.pre5"
3
+ VERSION = "0.13.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-nats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.pre5
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt