Module: Legion::Logging::Shipper::HttpTransport

Defined in:
lib/legion/logging/shipper/http_transport.rb

Class Method Summary collapse

Class Method Details

.ship(events) ⇒ Object



12
13
14
# File 'lib/legion/logging/shipper/http_transport.rb', line 12

def ship(events)
  ship_batch(events)
end

.ship_batch(events) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/legion/logging/shipper/http_transport.rb', line 16

def ship_batch(events)
  endpoint = resolve_endpoint
  return false unless endpoint

  uri   = URI(endpoint)
  batch = Array(events)
  body  = build_body(batch, uri)

  response = post(uri, body)
  response.is_a?(Net::HTTPSuccess)
rescue StandardError => e
  Legion::Logging.error("HttpTransport ship failed: #{e.message}") if defined?(Legion::Logging)
  false
end