Class: JobTick::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/jobtick/client.rb

Constant Summary collapse

TIMEOUT =
5

Instance Method Summary collapse

Instance Method Details

#ping(monitor_key, status:, duration: nil, message: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/jobtick/client.rb', line 11

def ping(monitor_key, status:, duration: nil, message: nil)
  return unless JobTick.config.enabled
  return if JobTick.config.api_key.nil?

  payload = { status: status }
  payload[:duration] = duration.round(3) if duration
  payload[:message]  = message           if message

  post("/ping/#{monitor_key}", payload)
end

#register(monitors) ⇒ Object



22
23
24
25
26
27
# File 'lib/jobtick/client.rb', line 22

def register(monitors)
  return unless JobTick.config.enabled
  return if JobTick.config.api_key.nil?

  post("/monitors/sync", { monitors: monitors })
end