Class: Fluent::Tranquility::Pusher

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/tranquility/pusher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, dataset) ⇒ Pusher

Returns a new instance of Pusher.



6
7
8
9
# File 'lib/fluent/tranquility/pusher.rb', line 6

def initialize(connection, dataset)
  @connection = connection
  @dataset    = dataset
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/fluent/tranquility/pusher.rb', line 4

def connection
  @connection
end

Instance Method Details

#call(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fluent/tranquility/pusher.rb', line 11

def call(data)
  res = connection.post("/v1/post/#{dataset}") do |req|
    req.headers['Content-Type'] = 'text/plain'
    req.body = data
    req.params['async'] = true
    req.options.timeout = 60
    req.options.open_timeout = 60
  end

  res.success?
end