Class: Droonga::FluentMessageReceiver::Client
- Inherits:
-
Object
- Object
- Droonga::FluentMessageReceiver::Client
- Includes:
- Loggable
- Defined in:
- lib/droonga/fluent_message_receiver.rb
Instance Attribute Summary collapse
-
#on_close ⇒ Object
Returns the value of attribute on_close.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(io, &on_message) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(io, &on_message) ⇒ Client
Returns a new instance of Client.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/droonga/fluent_message_receiver.rb', line 162 def initialize(io, &) @io = io @on_message = @on_close = nil @unpacker = MessagePack::Unpacker.new on_read = lambda do |data| feed(data) end @io.on_read do |data| on_read.call(data) end on_close = lambda do @io = nil @on_close.call if @on_close end @io.on_close do on_close.call end end |
Instance Attribute Details
#on_close ⇒ Object
Returns the value of attribute on_close.
161 162 163 |
# File 'lib/droonga/fluent_message_receiver.rb', line 161 def on_close @on_close end |
Instance Method Details
#close ⇒ Object
184 185 186 |
# File 'lib/droonga/fluent_message_receiver.rb', line 184 def close @io.close end |