Class: Fluent::BaritoBatchVMOutput

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

Constant Summary collapse

PLUGIN_NAME =
"barito_batch_vm"

Instance Method Summary collapse

Instance Method Details

#format(tag, time, record) ⇒ Object

Overide from BufferedOutput



24
25
26
# File 'lib/fluent/plugin/out_barito_batch_vm.rb', line 24

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#startObject

Overide from BufferedOutput



19
20
21
# File 'lib/fluent/plugin/out_barito_batch_vm.rb', line 19

def start
  super
end

#write(chunk) ⇒ Object

Overide from BufferedOutput



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_barito_batch_vm.rb', line 29

def write(chunk)
  data = {
    'items' => []
  }
  transport = Fluent::Plugin::BaritoTransport.new(@produce_url, log)
  chunk.msgpack_each do |tag, time, record|
    trail = Fluent::Plugin::ClientTrail.new(false)
    timber = Fluent::Plugin::TimberFactory::create_timber(tag, time, record, trail)

    data['items'] << timber
  end

  if @application_secret.nil? or @application_secret.empty?
      return if @application_group_secret.nil? or @application_name.nil?
      header = {
        content_type: :json,
        'X-App-Group-Secret' => @application_group_secret,
        'X-App-Name' => @application_name
      }
  else
    header = {content_type: :json, 'X-App-Secret' => @application_secret}
  end

  transport.send_compressed(data, header)
end