allq 0.3.8 → 0.3.9

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: 5a179d72534b0a07bb5b87d02bc7447a48078213
4
- data.tar.gz: d96e35f43118aa616418072ac35a121a757ee472
3
+ metadata.gz: 01b7850787c72b6525e92c9de5d8c92031f22400
4
+ data.tar.gz: e7e096efb7d8ade52b493b6ae6f63d7c6be145f9
5
5
  SHA512:
6
- metadata.gz: 31c4823fe3be1fa669e8316f328482e7f2651f23bd18cb388f0fac52b769ab13b957efd68dfee915a363d343c7612f10ebafeccd6d46b0a0bd8af369c768ef88
7
- data.tar.gz: 06a81172215aece6a413fe9de35f4f7fbab2cbe00a4664c746ab7fc8642cb6f2350354a84e8c7c35ce970afbfa8388802c2d56847245fdac5ef63a2c2467cfc7
6
+ metadata.gz: 19ff24d66cce5372cefe16da6a5c585823b363e5228bbf93da9196df6f5793544b51db6eecd56290f701fb23e48aea8bd0dc2b746425fcba8408a96b6bd20a62
7
+ data.tar.gz: 6e605b1a73b2e68455e06901dcda89329fa8feff0e8868fd894ad601f5a8dfe19feb75eb51b7e5a6330a2fe2515652967ddeac2b4517eed4aad387496c1845c5
data/lib/allq/client.rb CHANGED
@@ -92,7 +92,7 @@ class AllQ
92
92
 
93
93
  def reload!
94
94
  @connection.close if @connection
95
- puts "New --#{@url}"
95
+ puts "AllQ Connection Started --#{@url}"
96
96
  @connection = AllQ::Connection.new(@url)
97
97
  @get_action = AllQ::Get.new(@connection, self)
98
98
  @put_action = AllQ::Put.new(@connection, self)
@@ -30,8 +30,6 @@ class AllQ
30
30
  #
31
31
  def initialize(address = '')
32
32
  @address = address || _host_from_env
33
- @mutex = Mutex.new
34
- establish_connection
35
33
  rescue
36
34
  _raise_not_connected!
37
35
  end
@@ -46,7 +44,7 @@ class AllQ
46
44
  yield block.call(res)
47
45
  end
48
46
 
49
- def call_socat(data, timeout = 1.0)
47
+ def call_socat(data, timeout = 3.0)
50
48
  cmd_string = "echo '#{data}' | socat -t #{timeout} - tcp4-connect:#{@address}"
51
49
  output = `#{cmd_string}`
52
50
  return output
@@ -63,10 +61,9 @@ class AllQ
63
61
  #
64
62
  def transmit(command, options={}, &block)
65
63
  _with_retry(options[:retry_interval], options[:init]) do
66
- @mutex.synchronize do
67
- res = call_socat(command.to_s, 20.0)
68
- yield block.call(res)
69
- end
64
+ res = call_socat(command.to_s, 20.0)
65
+ raise "Socat failed after 20 seconds" if res.to_s == ""
66
+ yield block.call(res)
70
67
  end
71
68
  end
72
69
 
@@ -76,10 +73,6 @@ class AllQ
76
73
  # @conn.close
77
74
  #
78
75
  def close
79
- if @connection
80
- @connection.close
81
- @connection = nil
82
- end
83
76
  end
84
77
 
85
78
  # Returns string representation of job.
@@ -102,11 +95,6 @@ class AllQ
102
95
  # establish_connection('localhost:3005')
103
96
  #
104
97
  def establish_connection
105
- @address = address.first if address.is_a?(Array)
106
- match = address.split(':')
107
- @host, @port = match[0], Integer(match[1] || DEFAULT_PORT)
108
-
109
- @connection = TCPSocket.new @host, @port
110
98
  end
111
99
 
112
100
  private
@@ -121,6 +109,7 @@ class AllQ
121
109
  def _with_retry(retry_interval, init=true, tries=MAX_RETRIES, &block)
122
110
  yield
123
111
  rescue => ex
112
+ sleep(tries) if tries > 0
124
113
  _reconnect(ex, retry_interval)
125
114
  retry
126
115
  end
data/lib/allq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Allq
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler