nats-pure 2.4.0 → 2.6.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +10 -3
  4. data/lib/nats/client.rb +7 -3
  5. data/lib/nats/io/client.rb +464 -328
  6. data/lib/nats/io/errors.rb +2 -0
  7. data/lib/nats/io/jetstream/api.rb +53 -50
  8. data/lib/nats/io/jetstream/errors.rb +30 -14
  9. data/lib/nats/io/jetstream/js/config.rb +9 -3
  10. data/lib/nats/io/jetstream/js/header.rb +15 -9
  11. data/lib/nats/io/jetstream/js/status.rb +11 -5
  12. data/lib/nats/io/jetstream/js/sub.rb +4 -2
  13. data/lib/nats/io/jetstream/js.rb +10 -8
  14. data/lib/nats/io/jetstream/manager.rb +103 -101
  15. data/lib/nats/io/jetstream/msg/ack.rb +22 -12
  16. data/lib/nats/io/jetstream/msg/ack_methods.rb +30 -24
  17. data/lib/nats/io/jetstream/msg/metadata.rb +10 -7
  18. data/lib/nats/io/jetstream/msg.rb +11 -4
  19. data/lib/nats/io/jetstream/pull_subscription.rb +21 -10
  20. data/lib/nats/io/jetstream/push_subscription.rb +3 -1
  21. data/lib/nats/io/jetstream.rb +102 -106
  22. data/lib/nats/io/kv/api.rb +7 -3
  23. data/lib/nats/io/kv/bucket_status.rb +7 -5
  24. data/lib/nats/io/kv/errors.rb +25 -2
  25. data/lib/nats/io/kv/manager.rb +19 -10
  26. data/lib/nats/io/kv.rb +354 -22
  27. data/lib/nats/io/msg.rb +19 -19
  28. data/lib/nats/io/parser.rb +23 -23
  29. data/lib/nats/io/rails.rb +2 -0
  30. data/lib/nats/io/subscription.rb +33 -23
  31. data/lib/nats/io/version.rb +4 -2
  32. data/lib/nats/io/websocket.rb +40 -18
  33. data/lib/nats/nuid.rb +33 -22
  34. data/lib/nats/service/callbacks.rb +22 -0
  35. data/lib/nats/service/endpoint.rb +155 -0
  36. data/lib/nats/service/errors.rb +44 -0
  37. data/lib/nats/service/group.rb +37 -0
  38. data/lib/nats/service/monitoring.rb +108 -0
  39. data/lib/nats/service/stats.rb +52 -0
  40. data/lib/nats/service/status.rb +66 -0
  41. data/lib/nats/service/validator.rb +31 -0
  42. data/lib/nats/service.rb +121 -0
  43. data/lib/nats/utils/list.rb +26 -0
  44. data/lib/nats-pure.rb +5 -0
  45. data/lib/nats.rb +10 -6
  46. metadata +176 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a89824c45aafc2a28dbdfe35762fb3172c9210a54097456e8480630910cb741
4
- data.tar.gz: b2f99e1fee310ffc0a689f3bb956133ad694230bed23a6c9ad987c4634db6008
3
+ metadata.gz: 7d5c22758be6db2c05382a55c718c2c4f836a2c723f77820d4728bbf1538f30b
4
+ data.tar.gz: 1745fb8cfa406b598099779a027a3cc3dcc4cee28c22fd7c08e1b156b6ce4a5b
5
5
  SHA512:
6
- metadata.gz: 4b2c9b1b010e7701fbafa7e161d1dd915ee24830d72df6ef5455ad87a8d07e2493442c3986121d5556f19e91a2f55ec837938831da61917c7974187b7e8fcea1
7
- data.tar.gz: a914e41f74342ab9010f0728351fb1ac37992f71cd60b35448b1542b4818d12580a2792db9fd3ad63a00a08b0acaceff44c1c39f6f6acb7e0e764d40a26afd08
6
+ metadata.gz: 84b049092f60f34c3ca6b5a8ac2b4334a1a32dbaefd2659424f91db3472df105604bbddd4989793a56757a9cdee1c710db6b52fc02e40b95f64bc0b0eae21dd6
7
+ data.tar.gz: 38585616a5820faefe491c8c16d815bc52759e0cd2b7f77ab5b3a0227d3728720c4f1ac56d6d2af6354c2c53e54245ab48ce71c2a063efe3fe737e60e21c6af7
data/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Change log
2
+
3
+ ## main
4
+
5
+ ## v2.6.0
6
+
7
+ This release prepares nats-pure for nats-server 2.16, whose new JetStream
8
+ acknowledgement format breaks JetStream consumers and KV watchers in earlier
9
+ versions, and fixes a deadlock that could hang `Client#close`.
10
+
11
+ ### Changed
12
+
13
+ - With `reconnect: false`, losing the connection now closes the client, as nats.go does: the status becomes `CLOSED`, the close callback is called, and `publish` raises `NATS::IO::ConnectionClosedError`. It used to stay `DISCONNECTED` and keep accepting publishes that were never sent, because the close, started from the read loop, killed the read loop part way through. (#189)
14
+
15
+ ### Fixed
16
+
17
+ - JetStream: accept the 11-token acknowledgement subjects that nats-server 2.16 sends by default (the v2 format of ADR-15). Earlier versions fail to read the metadata of every JetStream message from such a server, which breaks pull and push consumers and KV watchers. (#185)
18
+ - JetStream: an unrecognized acknowledgement subject raises `NATS::JetStream::Error::NotJSMessage` instead of `NameError`, and subjects whose numeric fields do not parse are rejected. (#185)
19
+ - JetStream: message metadata timestamps keep their full nanosecond precision. (#185)
20
+ - KV: watchers track their position from message metadata, so they resume after a server restart with either acknowledgement format. (#185)
21
+ - `Client#close` could hang forever. It stopped the client's background threads with `Thread#exit`, and killing a thread that is waiting for the client lock can lose Ruby's mutex wakeup, leaving `close` asleep on an unlocked lock. The threads are now asked to stop and joined, on close and on reconnect. (#183, #189)
22
+ - A close while a reconnect was under way did not stick: the reconnect carried on, connected again and restarted the client, subscriptions included. (#189)
23
+ - A subscription with a concurrency limit could run its callbacks in parallel, and so out of order: an empty pending queue released the concurrency permit twice. (#186)
24
+ - A subscription could stop processing messages for good after a reconnect: shutting down the executor during dispatch killed the read loop and leaked the concurrency permit. (#182)
25
+ - WebSocket: protocol lines sharing a frame, such as the `PONG` and `INFO` that nats-server 2.12.2 sends together, were misparsed (#174, thanks @artyomb), and bytes that arrived with the reply to the connect handshake were lost. (#182, #186)
26
+ - JRuby: a refused connection raises `Errno::ECONNREFUSED`, as on MRI. (#182, #186)
27
+
28
+ ### Improved
29
+
30
+ - Tested against nats-server 2.14, 2.15 and the upcoming 2.16 (`main`), on Ruby 3.0 to 3.4 and JRuby. (#182, #188)
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # NATS - Pure Ruby Client
1
+ [![Gem Version](https://badge.fury.io/rb/nats-pure.svg)](https://rubygems.org/gems/nats-pure)
2
+ [![License Apache 2.0](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
3
+ [![Build](https://github.com/nats-io/nats-pure.rb/workflows/Build/badge.svg)](https://github.com/nats-io/nats-pure.rb/actions)
4
+ [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.nats.io/)
2
5
 
3
- A thread safe [Ruby](http://ruby-lang.org) client for the [NATS messaging system](https://nats.io) written in pure Ruby.
6
+ # NATS: Pure Ruby Client
4
7
 
5
- [![License Apache 2.0](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)[![Build Status](https://travis-ci.org/nats-io/nats-pure.rb.svg)](http://travis-ci.org/nats-io/nats-pure.rb)[![Gem Version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=rb&type=5&v=2.4.0)](https://rubygems.org/gems/nats-pure/versions/2.4.0)
8
+ A thread safe [Ruby](http://ruby-lang.org) client for the [NATS messaging system](https://nats.io) written in pure Ruby.
6
9
 
7
10
  ## Getting Started
8
11
 
@@ -99,6 +102,10 @@ loop do
99
102
  end
100
103
  ```
101
104
 
105
+ ## Service API
106
+
107
+ The service API allows you to easily [build NATS services](docs/service_api.md).
108
+
102
109
  ## Clustered Usage
103
110
 
104
111
  ```ruby
data/lib/nats/client.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2021 The NATS Authors
2
4
  # Licensed under the Apache License, Version 2.0 (the "License");
3
5
  # you may not use this file except in compliance with the License.
@@ -11,6 +13,8 @@
11
13
  # See the License for the specific language governing permissions and
12
14
  # limitations under the License.
13
15
  #
14
- require 'nats/io/client'
15
- require 'nats/io/rails' if defined?(Rails::Engine)
16
- require 'nats/nuid'
16
+ require "nats/utils/list"
17
+ require "nats/io/client"
18
+ require "nats/service"
19
+ require "nats/io/rails" if defined?(Rails::Engine)
20
+ require "nats/nuid"