sps-sub 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: 8d52f56bc416cad1645e9daebc0d9719ca7cf621
4
- data.tar.gz: db3cdf09db9a9f478d460d4586c5b4e303f123a0
3
+ metadata.gz: ecb177d9522017c32af93507a0e21968c4d78947
4
+ data.tar.gz: c7cd61be1e396a02663be49bfb9424a9d0d883a7
5
5
  SHA512:
6
- metadata.gz: 95f8b9642dfb34eedb057d23e1b4a005a4b9138ce4e5a0e9c8e9029d4e91684bd3b3a48bbb53c11bd7b2463fa6a2f882447711c42f5af45957e96d1ba3c0c75b
7
- data.tar.gz: 6865ba029b52186bead910b3e57a3d852259962f6ba368229a836a1d11824ce9249ba9c88a8907ce4deb2bad009b24a515681e361299caa36a1b463c97f9da78
6
+ metadata.gz: 4cfa0287c81d44bc5288c0142981303eb9a7fd9d35a61529ab3c59d556f3ef6a39226f23165b9333dd000e76fef7e77ea74914c1c839f753894fe3527f533dc2
7
+ data.tar.gz: a6ecc785b46fd145998cd8c2b824987d71ebc1c2211e4f63e6a383468daea9eaa0efe3139a535590e11a8b2fe7752d2584dc4f8d1eb917b35d9d3c16f8ee1dfd
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -7,12 +7,20 @@ require 'websocket-eventmachine-client'
7
7
 
8
8
  class SPSSub
9
9
 
10
- def initialize(port: '59000', host: nil, address: nil, callback: nil)
11
-
12
- @host = host || address || 'localhost'
13
- @port = port.to_s
10
+ def initialize(hosts: [], port: '59000', host: nil, address: nil, callback: nil )
11
+
12
+ if host.nil? and address.nil? and hosts.any? then
13
+ hostx, portx = hosts.first.split(':',2)
14
+ portx ||= port
15
+ @host, @port = hostx, portx
16
+ else
17
+ @host = host || address || 'localhost'
18
+ @port = port.to_s
19
+ end
20
+
14
21
  @callback = callback
15
22
  @retry_interval = 1
23
+ @hosts = hosts
16
24
 
17
25
  # Trap ^C
18
26
  Signal.trap("INT") {
@@ -83,12 +91,21 @@ class SPSSub
83
91
 
84
92
  return if @status == :quit
85
93
 
86
- @retry_interval *= 2
87
- sleep @retry_interval
88
- @retry_interval = 1 if @retry_interval > 30
89
-
90
- puts "retrying to connect to #{@host}:#{@port}... "
91
- client.em_connect topic
94
+ if @hosts.any? then
95
+
96
+ hostx, portx = @hosts.rotate!.first.split(':',2)
97
+ portx ||= @port
98
+ @host, @port = hostx, portx
99
+ client.em_connect topic
100
+
101
+ else
102
+ @retry_interval *= 2
103
+ sleep @retry_interval
104
+ @retry_interval = 1 if @retry_interval > 30
105
+
106
+ puts "retrying to connect to #{@host}:#{@port}... "
107
+ client.em_connect topic
108
+ end
92
109
  end
93
110
 
94
111
  ws.onerror do |error|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps-sub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  eWXz4xiizWWSrPuPJABF8HbFYS84edVCuWiEBU5ZWKNpKrx22oDT1PoyBa5tSK6G
32
32
  GFAzdFN+JAj2mQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-02-04 00:00:00.000000000 Z
34
+ date: 2017-05-20 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: websocket-eventmachine-client
metadata.gz.sig CHANGED
Binary file