Class: Fluent::Plugin::GroongaOutput::Emitter

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

Instance Method Summary collapse

Constructor Details

#initialize(client, table, schema) ⇒ Emitter

Returns a new instance of Emitter.



570
571
572
573
574
# File 'lib/fluent/plugin/out_groonga.rb', line 570

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

Instance Method Details

#emit(chunk) ⇒ Object



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/fluent/plugin/out_groonga.rb', line 582

def emit(chunk)
  records = []
  chunk.msgpack_each do |message|
    tag, _, record = message
    name = nil
    arguments = nil
    case tag
    when /\Agroonga\.command\./
      name = $POSTMATCH
      arguments = record
    when "groonga.command"
      name = record["name"]
      arguments = record["arguments"]
    end

    if name
      unless records.empty?
        store_records(records)
        records.clear
      end
      @client.execute(name, arguments)
      case name
      when /\A(?:table|column)_(?:create|remove)/
        @schema.clear_cache
      end
    else
      records << record
    end
  end
  store_records(records) unless records.empty?
end

#shutdownObject



579
580
# File 'lib/fluent/plugin/out_groonga.rb', line 579

def shutdown
end

#startObject



576
577
# File 'lib/fluent/plugin/out_groonga.rb', line 576

def start
end