Class: Droonga::FluentMessageReceiver::Client

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/droonga/fluent_message_receiver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, &on_message) ⇒ Client

Returns a new instance of Client.



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/droonga/fluent_message_receiver.rb', line 217

def initialize(io, &on_message)
  @io = io
  @on_message = on_message
  @on_close = nil
  @unpacker = MessagePack::Unpacker.new

  @io.on_read do |data|
    feed(data)
  end

  @io.on_close do
    @io = nil
    @on_close.call if @on_close
  end
end

Instance Attribute Details

#on_closeObject

Returns the value of attribute on_close.



216
217
218
# File 'lib/droonga/fluent_message_receiver.rb', line 216

def on_close
  @on_close
end

Instance Method Details

#closeObject



233
234
235
# File 'lib/droonga/fluent_message_receiver.rb', line 233

def close
  @io.close
end