Class: GemeraldBeanstalk::Plugin::DirectConnection::Client
- Inherits:
-
Object
- Object
- GemeraldBeanstalk::Plugin::DirectConnection::Client
- Defined in:
- lib/gemerald_beanstalk/plugins/direct_connection/client.rb
Instance Attribute Summary collapse
-
#beanstalk ⇒ Object
readonly
Returns the value of attribute beanstalk.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #close_connection ⇒ Object
-
#initialize(beanstalk) ⇒ Client
constructor
A new instance of Client.
- #send_data(message) ⇒ Object
- #transmit(message) ⇒ Object
Constructor Details
#initialize(beanstalk) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 13 def initialize(beanstalk) @beanstalk = beanstalk @connection = beanstalk.connect(self) @async_response = nil end |
Instance Attribute Details
#beanstalk ⇒ Object (readonly)
Returns the value of attribute beanstalk.
4 5 6 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 4 def beanstalk @beanstalk end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 4 def connection @connection end |
Instance Method Details
#close_connection ⇒ Object
6 7 8 9 10 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 6 def close_connection return unless connection.alive? connection.close_connection beanstalk.disconnect(self) end |
#send_data(message) ⇒ Object
31 32 33 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 31 def send_data() @async_response = end |
#transmit(message) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/gemerald_beanstalk/plugins/direct_connection/client.rb', line 20 def transmit() += "\r\n" unless [-2, 2] == "\r\n" connection.execute() while (async_response = @async_response).nil? sleep 0.1 end @async_response = nil return async_response end |