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.



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, &on_message)
  @io = io
  @on_message = 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_closeObject

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

#closeObject



184
185
186
# File 'lib/droonga/fluent_message_receiver.rb', line 184

def close
  @io.close
end