Class: Fluent::Plugin::GroongaOutput::Emitter
- Inherits:
-
Object
- Object
- Fluent::Plugin::GroongaOutput::Emitter
- Defined in:
- lib/fluent/plugin/out_groonga.rb
Instance Method Summary collapse
- #emit(chunk) ⇒ Object
-
#initialize(client, table, schema) ⇒ Emitter
constructor
A new instance of Emitter.
- #shutdown ⇒ Object
- #start ⇒ Object
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 || tag, _, record = 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 |
#shutdown ⇒ Object
579 580 |
# File 'lib/fluent/plugin/out_groonga.rb', line 579 def shutdown end |
#start ⇒ Object
576 577 |
# File 'lib/fluent/plugin/out_groonga.rb', line 576 def start end |