Class: Fluent::GroongaOutput::Emitter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_groonga.rb,
lib/fluent/plugin/out_groonga.rb

Instance Method Summary (collapse)

Constructor Details

- (Emitter) initialize(client, table, schema)

Returns a new instance of Emitter



276
277
278
279
280
# File 'lib/fluent/plugin/out_groonga.rb', line 276

def initialize(client, table)
  @client = client
  @table = table
  @schema = nil
end

Instance Method Details

- (Object) emit(chunk)



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/fluent/plugin/out_groonga.rb', line 289

def emit(chunk)
  records = []
  chunk.msgpack_each do |message|
    tag, _, record = message
    if /\Agroonga\.command\./ =~ tag
      name = $POSTMATCH
      unless records.empty?
        store_records(records)
        records.clear
      end
      @client.execute(name, record)
    else
      records << record
    end
  end
  store_records(records) unless records.empty?
end

- (Object) shutdown



286
287
# File 'lib/fluent/plugin/out_groonga.rb', line 286

def shutdown
end

- (Object) start



282
283
284
# File 'lib/fluent/plugin/out_groonga.rb', line 282

def start
  @schema = Schema.new(@client, @table)
end