allq 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/allq/connection.rb +14 -17
- data/lib/allq/job.rb +4 -0
- data/lib/allq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89cc071fa78a00b3bbda7e21cacfc4cbe20d992c
|
4
|
+
data.tar.gz: d0aecf251d0587c8e0d01f2bdf39099a82f3891b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43cb8d3c2614a46e6e5167613381040487b55aeb6df5cc6e50d4fc705456a5b4c112c9d3c3f8f4bdec17c02c0e40f25edfba12e3a151b47c0667784b873b9f5b
|
7
|
+
data.tar.gz: 0ba32f6101c5a53402697c857d2b2783af11847272b8f9ac65a4a0ae592a71bf7e7472705b3fa509b785a0869f12ded5d049171b2702a734eb0aca9f37dc95b2
|
data/lib/allq/connection.rb
CHANGED
@@ -30,7 +30,6 @@ class AllQ
|
|
30
30
|
#
|
31
31
|
def initialize(address = '')
|
32
32
|
@address = address || _host_from_env
|
33
|
-
@mutex = Mutex.new
|
34
33
|
establish_connection
|
35
34
|
rescue
|
36
35
|
_raise_not_connected!
|
@@ -47,25 +46,29 @@ class AllQ
|
|
47
46
|
#
|
48
47
|
def transmit(command, options={}, &block)
|
49
48
|
_with_retry(options[:retry_interval], options[:init]) do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
res = @connection.readline
|
54
|
-
yield block.call(res)
|
49
|
+
send_string = command.to_s
|
50
|
+
if send_string.include?("'")
|
51
|
+
puts "Single quotes not allow in JSON. This will probably error."
|
55
52
|
end
|
53
|
+
res = call_socat(send_string)
|
54
|
+
_raise_not_connected if res.include?("Connection refused")
|
55
|
+
yield block.call(res)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
def call_socat(data)
|
60
|
+
cmd_string = "echo '#{data}' | socat - tcp4-connect:#{address}"
|
61
|
+
output = `#{cmd_string}`
|
62
|
+
return output
|
63
|
+
end
|
64
|
+
|
59
65
|
# Close connection with allq server.
|
60
66
|
#
|
61
67
|
# @example
|
62
68
|
# @conn.close
|
63
69
|
#
|
64
70
|
def close
|
65
|
-
|
66
|
-
@connection.close
|
67
|
-
@connection = nil
|
68
|
-
end
|
71
|
+
# no_op
|
69
72
|
end
|
70
73
|
|
71
74
|
# Returns string representation of job.
|
@@ -74,7 +77,7 @@ class AllQ
|
|
74
77
|
# @conn.inspect
|
75
78
|
#
|
76
79
|
def to_s
|
77
|
-
"#<AllQ::Connection
|
80
|
+
"#<AllQ::Connection address=#{address}>"
|
78
81
|
end
|
79
82
|
alias :inspect :to_s
|
80
83
|
|
@@ -88,11 +91,6 @@ class AllQ
|
|
88
91
|
# establish_connection('localhost:3005')
|
89
92
|
#
|
90
93
|
def establish_connection
|
91
|
-
@address = address.first if address.is_a?(Array)
|
92
|
-
match = address.split(':')
|
93
|
-
@host, @port = match[0], Integer(match[1] || DEFAULT_PORT)
|
94
|
-
|
95
|
-
@connection = TCPSocket.new @host, @port
|
96
94
|
end
|
97
95
|
|
98
96
|
private
|
@@ -118,7 +116,6 @@ class AllQ
|
|
118
116
|
# @param [Integer] tries The maximum number of attempts to reconnect
|
119
117
|
def _reconnect(original_exception, retry_interval, tries=MAX_RETRIES)
|
120
118
|
close
|
121
|
-
establish_connection
|
122
119
|
rescue Errno::ECONNREFUSED
|
123
120
|
tries -= 1
|
124
121
|
if tries.zero?
|
data/lib/allq/job.rb
CHANGED
data/lib/allq/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.5
|
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-
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|