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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ef014bf42e3b2aae0712a29d16dbfe84250f37f
4
- data.tar.gz: 47e014a2bee172ace5f140df9f1705a64f6a2a26
3
+ metadata.gz: 89cc071fa78a00b3bbda7e21cacfc4cbe20d992c
4
+ data.tar.gz: d0aecf251d0587c8e0d01f2bdf39099a82f3891b
5
5
  SHA512:
6
- metadata.gz: '0496073b8f00999644900528ce4fbf3e8debb3bda574d4febde0a3b4c13ee6e6a5ada6ab91eafb4a63b4b9946299d206f286032663ce2d6921d107b245c78f28'
7
- data.tar.gz: 17d369cd64192b6a0eab7bf8334e32bfc21637fbe09e6a849984a0cccbd6cab79a6618da78be0d5dd9ab1c2c951c08375a2d72dbeb7682bbbd2348cd0cc65aea
6
+ metadata.gz: 43cb8d3c2614a46e6e5167613381040487b55aeb6df5cc6e50d4fc705456a5b4c112c9d3c3f8f4bdec17c02c0e40f25edfba12e3a151b47c0667784b873b9f5b
7
+ data.tar.gz: 0ba32f6101c5a53402697c857d2b2783af11847272b8f9ac65a4a0ae592a71bf7e7472705b3fa509b785a0869f12ded5d049171b2702a734eb0aca9f37dc95b2
@@ -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
- @mutex.synchronize do
51
- _raise_not_connected! unless @connection && !@connection.closed?
52
- @connection.puts(command.to_s)
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
- if @connection
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 host=#{host.inspect} port=#{port.inspect}>"
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
@@ -59,6 +59,10 @@ class AllQ
59
59
  }
60
60
  end
61
61
 
62
+ def reload_client
63
+ @client.reload!
64
+ end
65
+
62
66
  def self.new_from_hash(hash, client)
63
67
  begin
64
68
  id = hash.fetch('job_id')
data/lib/allq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Allq
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
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.4
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-17 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler