Class: Wildsight::Transport::NetHttpTransport

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

Instance Method Summary collapse

Constructor Details

#initialize(agent, config) ⇒ NetHttpTransport

Returns a new instance of NetHttpTransport.



8
9
10
11
12
# File 'lib/wildsight/transport/net_http.rb', line 8

def initialize(agent, config)
  @agent = agent
  @config = config
  @uri = URI(File.join(@config['transport']['url'], 'ingest', @config['transport']['key']))
end

Instance Method Details

#send(payload) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/wildsight/transport/net_http.rb', line 14

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