nats-pure 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d21f9a3f83d1aaa172f0835a2d74b5109a8e937429550981427b84325f97f1d3
4
- data.tar.gz: 48ea0ef20a7c2611023573f883384d15ebf6bf9c342f37336b25157d79963098
3
+ metadata.gz: 1283c1d3b53b281eec2c1fb01643b3efd51c7b2468a54006f4afc9b0aa6cfffd
4
+ data.tar.gz: d6777d4b80d57b44da776e75be073f67fd76c3a7d23cf66fa7a2dc96f74afe64
5
5
  SHA512:
6
- metadata.gz: b72826e0d687cee2e303f3fae2abbc34ad6fe10ce35967d2201ecd3838c27f186e70c99c880288bfd2fbdc840edebfa80f4f31e282caafb15f899b41301a5a94
7
- data.tar.gz: b5328d07ffa92de70d32cb37b28bf1c08db2866b58902dee2f761b6c0cf758c18037262fca4f42a3ab5bf6c4f0663abb733d8322cdfe8a2e30d8bd9de9a4139f
6
+ metadata.gz: bb44bb3872296a3cce5416777b2e85c5c2046fb64a545157fd3661754a31311b9bf2d032494d5eb1e34a08c1e0d2f3982538a098f0066f30c2a5c16823ee8ec8
7
+ data.tar.gz: f5a2e1f1a836392030c1abc0d8ee65a3b19e2bb371d7c3cae0c8107ae5444a13609275f85c6ec12c06070218e1220ec36bb57eba4d8a7c86b4ac314eba6ddc4e
@@ -28,6 +28,15 @@ rescue LoadError
28
28
  end
29
29
 
30
30
  module NATS
31
+ class << self
32
+ def connect(uri=nil, opts={})
33
+ nc = NATS::IO::Client.new
34
+ nc.connect(uri, opts)
35
+
36
+ nc
37
+ end
38
+ end
39
+
31
40
  module IO
32
41
 
33
42
  DEFAULT_PORT = 4222
@@ -185,6 +194,9 @@ module NATS
185
194
  @hostname = nil
186
195
  @single_url_connect_used = false
187
196
 
197
+ # Track whether connect has been already been called.
198
+ @connect_called = false
199
+
188
200
  # New style request/response implementation.
189
201
  @resp_sub = nil
190
202
  @resp_map = nil
@@ -201,6 +213,15 @@ module NATS
201
213
 
202
214
  # Establishes connection to NATS.
203
215
  def connect(uri=nil, opts={})
216
+ synchronize do
217
+ # In case it has been connected already, then do not need to call this again.
218
+ return if @connect_called
219
+ @connect_called = true
220
+ end
221
+
222
+ # Convert URI to string if needed.
223
+ uri = uri.to_s if uri.is_a?(URI)
224
+
204
225
  case uri
205
226
  when String
206
227
  # Initialize TLS defaults in case any url is using it.
@@ -615,6 +636,11 @@ module NATS
615
636
  end
616
637
  response = sub.response
617
638
 
639
+ if response and response.header
640
+ status = response.header[STATUS_HDR]
641
+ raise NoRespondersError if status == "503"
642
+ end
643
+
618
644
  response
619
645
  end
620
646
 
@@ -1,4 +1,4 @@
1
- # Copyright 2016-2018 The NATS Authors
1
+ # Copyright 2016-2021 The NATS Authors
2
2
  # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
@@ -15,7 +15,7 @@
15
15
  module NATS
16
16
  module IO
17
17
  # NOTE: These are all announced to the server on CONNECT
18
- VERSION = "0.7.0"
18
+ VERSION = "0.7.2"
19
19
  LANG = "#{RUBY_ENGINE}#{RUBY_VERSION}".freeze
20
20
  PROTOCOL = 1
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats-pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Waldemar Quevedo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: NATS is an open-source, high-performance, lightweight cloud messaging
14
14
  system.