Class: Fluent::Plugin::BaritoTransport
- Inherits:
-
Object
- Object
- Fluent::Plugin::BaritoTransport
- Defined in:
- lib/fluent/plugin/barito_transport.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#produce_url ⇒ Object
Returns the value of attribute produce_url.
Instance Method Summary collapse
-
#initialize(produce_url, logger) ⇒ BaritoTransport
constructor
A new instance of BaritoTransport.
- #send(timber, header) ⇒ Object
- #send_compressed(timber, header) ⇒ Object
Constructor Details
#initialize(produce_url, logger) ⇒ BaritoTransport
Returns a new instance of BaritoTransport.
8 9 10 11 |
# File 'lib/fluent/plugin/barito_transport.rb', line 8 def initialize(produce_url, logger) @produce_url = produce_url @logger = logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/fluent/plugin/barito_transport.rb', line 6 def logger @logger end |
#produce_url ⇒ Object
Returns the value of attribute produce_url.
6 7 8 |
# File 'lib/fluent/plugin/barito_transport.rb', line 6 def produce_url @produce_url end |
Instance Method Details
#send(timber, header) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/fluent/plugin/barito_transport.rb', line 13 def send(timber, header) begin RestClient.post @produce_url, timber.to_json, header rescue Exception => e @logger.error [e., e.response, header].join(', ') end end |
#send_compressed(timber, header) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fluent/plugin/barito_transport.rb', line 21 def send_compressed(timber, header) begin header['Content-Encoding'] = 'gzip' gz = Zlib::GzipWriter.new(StringIO.new) gz << timber.to_json RestClient.post @produce_url, gz.close.string, header rescue Exception => e puts(header) @logger.error [e., e.response, Hash[header.collect{|k,v| [k.to_s, v]}]].join(', ') end end |