Sha256: 587c4605a5ae39e596077023a06d1625dda59ec09d179955e5e55091479a0756

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

require 'json'

module AppMonit
  class Event
    def self.create(*args)
      create!(*args)
    rescue Http::Error
      false
    rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
        Net::HTTPHeaderSyntaxError, Net::ProtocolError => error
      raise error unless AppMonit::Config.fail_silent
      false
    end

    def self.create!(name, data_hash = {})
      created_at = data_hash.delete(:created_at) || Time.now.utc

      message = { created_at: created_at, name: name, payload: data_hash }
      client.post('/v1/events', message)
    end

    def self.client
      Http
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
app_monit-0.0.2 lib/app_monit/event.rb