Class: Wildsight::Transport::FaradayTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/wildsight/transport/faraday.rb

Instance Method Summary collapse

Constructor Details

#initialize(agent, config) ⇒ FaradayTransport

Returns a new instance of FaradayTransport.



6
7
8
9
10
11
12
13
14
15
# File 'lib/wildsight/transport/faraday.rb', line 6

def initialize(agent, config)
  @agent = agent
  @config = config
  @connection = Faraday.new(:url => @config['transport']['url']) do |faraday|
    faraday.request(:multipart)
    faraday.request(:url_encoded)
    faraday.adapter(Faraday.default_adapter)
  end
  @uri = File.join('ingest', @config['transport']['key'])
end

Instance Method Details

#send(payload) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/wildsight/transport/faraday.rb', line 17

def send(payload)
  begin
    @agent.logger.log(:debug) { @connection.post(@uri, payload: MultiJson.dump(payload)).inspect }
  rescue Exception => e
    @agent.logger.log(:error) { e }
  end
end