perennial 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/perennial.rb CHANGED
@@ -9,7 +9,7 @@ require 'perennial/exceptions'
9
9
 
10
10
  module Perennial
11
11
 
12
- VERSION = [1, 2, 3]
12
+ VERSION = [1, 2, 4]
13
13
 
14
14
  has_library :dispatchable, :hookable, :loader, :logger, :nash,
15
15
  :loggable, :manifest, :settings, :argument_parser,
@@ -49,15 +49,18 @@ class Perennial::Protocols::PureRuby::JSONTransport
49
49
  "payload" => payload,
50
50
  "sent-at" => Time.now
51
51
  }.merge(callback_options(callback))) + SEPERATOR
52
- with_socket { |s| s.write(message) }
52
+ with_socket do |s|
53
+ raise NoConnection, "no connection the server at #{@host}:#{@port}" if s.nil?
54
+ s.write(message)
55
+ end
53
56
  end
54
57
 
55
- def read_message
58
+ def read_message(timeout = nil)
56
59
  with_socket do |s|
57
60
  raise NoConnection, "no connection the server at #{@host}:#{@port}" if s.nil?
58
61
  message = nil
59
62
  begin
60
- Perennial::TimerImplementation.timeout(timeout) do
63
+ Perennial::TimerImplementation.timeout(timeout || @timeout) do
61
64
  message = JSON.parse(s.gets.strip)
62
65
  end
63
66
  rescue Timeout::Error
@@ -118,7 +121,6 @@ class Perennial::Protocols::PureRuby::JSONTransport
118
121
  @socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
119
122
  @retry = nil
120
123
  rescue SocketError, SystemCallError, IOError, Timeout::Error => err
121
- # TODO: Raise a connection error here
122
124
  dead!
123
125
  end
124
126
  @socket
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perennial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock