Class: Sanford::Worker::Connection
- Inherits:
-
Object
- Object
- Sanford::Worker::Connection
- Defined in:
- lib/sanford/worker.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
1
Instance Attribute Summary collapse
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #close ⇒ Object
- #close_write ⇒ Object
-
#initialize(socket) ⇒ Connection
constructor
A new instance of Connection.
- #peek_data ⇒ Object
- #read_data ⇒ Object
- #write_data(data) ⇒ Object
Constructor Details
#initialize(socket) ⇒ Connection
Returns a new instance of Connection.
40 41 42 43 44 |
# File 'lib/sanford/worker.rb', line 40 def initialize(socket) @socket = socket @connection = Sanford::Protocol::Connection.new(@socket) @timeout = (ENV['SANFORD_TIMEOUT'] || DEFAULT_TIMEOUT).to_f end |
Instance Attribute Details
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
38 39 40 |
# File 'lib/sanford/worker.rb', line 38 def timeout @timeout end |
Instance Method Details
#close ⇒ Object
54 |
# File 'lib/sanford/worker.rb', line 54 def close; @connection.close; end |
#close_write ⇒ Object
55 |
# File 'lib/sanford/worker.rb', line 55 def close_write; @connection.close_write; end |
#peek_data ⇒ Object
53 |
# File 'lib/sanford/worker.rb', line 53 def peek_data; @connection.peek(@timeout); end |
#read_data ⇒ Object
52 |
# File 'lib/sanford/worker.rb', line 52 def read_data; @connection.read(@timeout); end |