nats-rpc 0.0.5 → 0.0.6

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: 67bf64491db922669d63fb1d600dadf236e34600b5d5836412d3fce8a8f37ac0
4
- data.tar.gz: 9e2fe08574804379047d5fff808b652cf793d0df1f11b27a7399c2ab5c8af5e7
3
+ metadata.gz: f9e1e675466128c8955d358476930522ed05bfc3caa75a1808af4193b7ccf53f
4
+ data.tar.gz: c8a3a6a30fbfcb12df6021fbe66f1c1bf513de4f515dcd705ae7b973ddc5072e
5
5
  SHA512:
6
- metadata.gz: c761af0486194d2ac948375e5e9ea9a7d890b535e538258479ec7c293b1df78f1d1813d6547cec3d37dcaa4604dc01cffc2db751058e8ea0cba8e3bd01f15dfd
7
- data.tar.gz: '095faca1a3e9df4b422700af6e3593d3104d1c80b0144ddf5602cb3f6402cc147b2e048d5c2a3f15b611756aab4e9f728f8362e248f2be964fc671aadc4d3f8c'
6
+ metadata.gz: b317536c7b99816481efcf55920fc07be30c04c276396f5a914640320a3effa3ed7bf0968715c2846a83bd1acdafaac41431622cbae1632e3e737fcf37890f96
7
+ data.tar.gz: d055605d4da3cdf85c1016efbd2a026047d7f41d75dbec9be50b55713be47988568485b582a3deb766273bff83f5bf6747365179f7c5f47b97db5d61aea2a1ac
@@ -2,12 +2,8 @@ module NATS
2
2
  module RPC
3
3
  class Client
4
4
  def initialize(cluster_opts=nil)
5
- cluster_opts = {
6
- servers: ["nats://127.0.0.1:4222"]
7
- } unless cluster_opts
8
-
9
5
  @nats = NATS::IO::Client.new
10
- @nats.connect cluster_opts
6
+ @nats.connect cluster_opts || NATS::RPC.cluster_opts
11
7
  end
12
8
 
13
9
  def request(subscription, obj, opts)
@@ -4,12 +4,8 @@ module NATS
4
4
  def initialize(id: SecureRandom.uuid, **cluster_opts)
5
5
  @id = id
6
6
 
7
- cluster_opts = {
8
- servers: ["nats://127.0.0.1:4222"]
9
- } unless cluster_opts
10
-
11
7
  @nats = NATS::IO::Client.new
12
- @nats.connect cluster_opts
8
+ @nats.connect cluster_opts || NATS::RPC.cluster_opts
13
9
 
14
10
  @count_json_parse_errors = 0
15
11
  @count_block_call_errors = 0
@@ -1,5 +1,5 @@
1
1
  module NATS
2
2
  module RPC
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/lib/nats/rpc.rb CHANGED
@@ -8,5 +8,24 @@ require_relative "rpc/client"
8
8
 
9
9
  module NATS
10
10
  module RPC
11
+ def self.cluster_opts
12
+ servers = ENV['NATS_RPC_SERVER_URLS']&.split(",")
13
+ max_reconnect_attempts = ENV['NATS_RPC_MAX_RECONNECT_ATTEMPTS']&.to_i
14
+ reconnect_time_wait = ENV['NATS_RPC_RECONNECT_TIME_WAIT']&.to_i
15
+
16
+ opts = {}
17
+ opts[:servers] = servers if servers
18
+ opts[:max_reconnect_attempts] = max_reconnect_attempts if max_reconnect_attempts
19
+ opts[:reconnect_time_wait] = reconnect_time_wait if reconnect_time_wait
20
+ if ENV['NATS_RPC_DONT_RANDOMIZE_SERVERS']
21
+ opts[:dont_randomize_servers] = ENV['NATS_RPC_DONT_RANDOMIZE_SERVERS'] == "true"
22
+ end
23
+ if ENV['NATS_RPC_RECONNECT']
24
+ opts[:reconnect] = ENV['NATS_RPC_RECONNECT'] == "true"
25
+ end
26
+
27
+ p opts
28
+ opts
29
+ end
11
30
  end
12
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats-rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matti Paksula
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nats-pure