sps-pub 0.5.4 → 0.5.5

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
  SHA1:
3
- metadata.gz: 2a37d094ea90ccab8b4bdaf0045a40806508cc31
4
- data.tar.gz: 5bc899cbfcb79ba90f60d6fca41e511806d39983
3
+ metadata.gz: 52c91d44b43fef7ae091fab8f32c6480e139d5d5
4
+ data.tar.gz: 45c21e14f76fca058a807113cbc60a529a3a22cc
5
5
  SHA512:
6
- metadata.gz: c8fb5d44f8fc8ab19f264bd4374858036d8e2da0488e685aa7c1364d6afdcd201259e18125e5d231496eca72e5c68b1e21abbd615c511ce8672275e6c49ad626
7
- data.tar.gz: 1e698d68d3e730575f3f3db951c9bf93fa824d6f62e3ec2333fc9a17a843e1f93971770af5766cca5b229b3ab3f6aae5847e277705c45a8cf8042e7ef3c28102
6
+ metadata.gz: 2feb85533ff56a7d5bedebc2bfca6f2478195054921e53ae4e7b8836bfe3e87998d7a963103e741f1e7ed1714152e1fb978781957f216ffee96e9dff5317fa43
7
+ data.tar.gz: 0f74e3a7ac22a7134635aeca86e588f1c6338ef9f53c01c9243d8599c460e0d09cbc4b730cc42df164300cfc75534e15743b7e2b01e820c2adadbfd356b4bf80
@@ -1,5 +1,3 @@
1
- ���n��{H�2fS�u0��N-X�_��2US@b���t�o�Sy�'�KC�^�D><��
2
- �����
3
- �ٶ�E��Cf�;�$����Cs7r��1�@P�#cm]���Ou6T�M~.�M}�k;��
4
- � !9Z�{��sR�S[q8~�p��T(�p-5�n1�$��=K��p:���rH�� ��°l�
5
- �l ����b!�mj��0�`8E�YdFbY0E956��` q�b�� �� >M|�dJ�ٮS屁Y�IR�
1
+ ���%�kr&0t���_i9D��6נ��qY��ҍ�s:2
2
+ �Cj�g���5)��O!�a��yk<�b`t��n)_�.E�\�{�o� $�َ��/@W䙥��? uC�_I�TC�e
3
+ B���j�1�k�Є���G��c8�s�$��("�%4�$�J�{��5�t��BX��]3Q����"c�Wʔ�V��AxH�3YBZ�V��ۑ(r���: ��z^��3�c�M(I���0���d.�,���;���,Ᏹ
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- yw�������?okEXt�I���r��t`��S��6��r�u��V�-���l�,�Co����� i��PW6 ���&�V��ye �(s���y�Y�}��{��Cmǡ|������#8��`6a���� ��N�gͩ�:�
2
- Y�g ��Z�.�@�G�-ɜ�Q@���5��|�82�� ߉BD1d
1
+ �%�e;� !�,�UNN���' �^����G�V
2
+ ��%p��G�?b���0ڌWCq?�e%�X�ȱ!;��Y��"ڴ�<m��J�%kEV�������¾�"W]�5x�(m�*_���)��dK���s7{�6�{���ۍ �h5�2۬��Z�%��C
3
+ �׮`\��hD��?�U-v� �x��ٯ��niB�>��]�$��+-C�f>'����!7�7�p��V�U���F@��aMIDq��ߘ� 
@@ -5,6 +5,10 @@
5
5
  require 'websocket-client-simple'
6
6
 
7
7
 
8
+ class SPSPubError < Exception
9
+ end
10
+
11
+
8
12
  class SPSPub
9
13
 
10
14
  def initialize(host: 'sps', address: host, port: '59000')
@@ -22,10 +26,33 @@ class SPSPub
22
26
  alias publish notice
23
27
 
24
28
  def self.notice(s, hostx='sps', host: hostx, address: host,
25
- port: '59000', retries: 3)
29
+ port: '59000', retries: 3, hosts: [])
30
+
26
31
 
32
+ ws = nil
33
+ begin
34
+
35
+ if hosts.any? then
36
+ address, portx = hosts.first.split(':', 2)
37
+
38
+ portx ||= port
39
+ port = portx
40
+ end
27
41
 
28
- ws = WebSocket::Client::Simple.connect "ws://%s:%s/" % [address, port]
42
+ ws = WebSocket::Client::Simple.connect "ws://%s:%s/" % [address, port]
43
+ rescue Errno::ECONNREFUSED => e
44
+
45
+ if hosts.any? then
46
+ hosts.rotate!
47
+ puts 'retrying ...' + hosts.inspect
48
+ sleep 0.1
49
+ #self.notice s, hosts: hosts.rotate
50
+ retry
51
+ else
52
+ raise SPSPubError, "connection refused"
53
+ end
54
+
55
+ end
29
56
 
30
57
  ws.on :open do
31
58
 
@@ -34,7 +61,11 @@ class SPSPub
34
61
  begin
35
62
 
36
63
  ws.send s
37
-
64
+
65
+ #exception
66
+
67
+ rescue Exception => e
68
+ puts 'dig it'
38
69
  rescue Errno::ETIMEDOUT => e
39
70
 
40
71
  if retries and retry_attempts < retries then
@@ -46,6 +77,7 @@ class SPSPub
46
77
  else
47
78
  puts 'SPSPub timeout while trying to contact the host'
48
79
  end
80
+
49
81
 
50
82
  end
51
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps-pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Ke//2Urv5XozW5nKniqR+yI7YVIlgDHWEjHdlCaQH3fMHsliDCeDF/lxRd902EDM
32
32
  pCvgnGqKZoDb7g==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-01-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-client-simple
metadata.gz.sig CHANGED
Binary file