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 +4 -4
- data/CHANGELOG.md +21 -4
- data/Gemfile +3 -0
- data/README.md +21 -8
- data/lib/protobuf/nats/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: dd9d0e1d6f565a66e972312fa19398f5b027c426b363672b5aa96b5a61f00595
|
|
4
|
+
data.tar.gz: c253885854d9bafcd5e714f8f1ff2afdb1193758d394f42c91ebf58f70865bd6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
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
|
|
57
|
-
few params which cannot be set: `servers`, `uses_tls`, `subscription_key_replacements`, and `connect_timeout`, so those
|
|
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
|
-
##
|
|
152
|
-
|
|
153
|
-
|
|
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
|
|