Class: Appsignal::CheckIn::Event Private

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/check_in/event.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.cron(identifier:, digest:, kind:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
# File 'lib/appsignal/check_in/event.rb', line 18

def cron(identifier:, digest:, kind:)
  new(
    :check_in_type => "cron",
    :identifier => identifier,
    :digest => digest,
    :kind => kind
  )
end

.describe(events) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/appsignal/check_in/event.rb', line 51

def describe(events)
  if events.empty?
    # This shouldn't happen.
    "no check-in events"
  elsif events.length > 1
    "#{events.length} check-in events"
  else
    event = events.first
    if event[:check_in_type] == "cron"
      "cron check-in `#{event[:identifier] || "unknown"}` " \
        "#{event[:kind] || "unknown"} event (digest #{event[:digest] || "unknown"})"
    elsif event[:check_in_type] == "heartbeat"
      "heartbeat check-in `#{event[:identifier] || "unknown"}` event"
    else
      "unknown check-in event"
    end
  end
end

.heartbeat(identifier:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
30
31
32
# File 'lib/appsignal/check_in/event.rb', line 27

def heartbeat(identifier:)
  new(
    :check_in_type => "heartbeat",
    :identifier => identifier
  )
end

.new(check_in_type:, identifier:, digest: nil, kind: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
# File 'lib/appsignal/check_in/event.rb', line 8

def new(check_in_type:, identifier:, digest: nil, kind: nil)
  {
    :identifier => identifier,
    :digest => digest,
    :kind => kind,
    :timestamp => Time.now.utc.to_i,
    :check_in_type => check_in_type
  }.compact
end

.redundant?(event, other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appsignal/check_in/event.rb', line 34

def redundant?(event, other)
  return false if
    other[:check_in_type] != event[:check_in_type] ||
      other[:identifier] != event[:identifier]

  return false if event[:check_in_type] == "cron" && (
    other[:digest] != event[:digest] ||
    other[:kind] != event[:kind]
  )

  return false if
    event[:check_in_type] != "cron" &&
      event[:check_in_type] != "heartbeat"

  true
end