Class: OkComputer::PusherCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/ok_computer/checks/pusher_check.rb

Constant Summary collapse

ChannelError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, app_id: nil, app_key: nil, app_secret: nil, app_cluster: nil) ⇒ PusherCheck

rubocop:disable Lint/MissingSuper



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ok_computer/checks/pusher_check.rb', line 11

def initialize(client: nil, app_id: nil, app_key: nil, app_secret: nil, app_cluster: nil) # rubocop:disable Lint/MissingSuper
  client ||= Pusher::Client.new(
    app_id: app_id,
    key: app_key,
    secret: app_secret,
    cluster: app_cluster,
    use_tls: true,
  )

  self.client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



9
10
11
# File 'lib/ok_computer/checks/pusher_check.rb', line 9

def client
  @client
end

Instance Method Details

#checkObject

Public: Return the status of the Channels check



24
25
26
27
28
29
30
# File 'lib/ok_computer/checks/pusher_check.rb', line 24

def check
  perform_request
  mark_message("Channels check successful")
rescue StandardError => e
  mark_message("Error: '#{e}'")
  mark_failure
end

#perform_requestObject



32
33
34
35
36
# File 'lib/ok_computer/checks/pusher_check.rb', line 32

def perform_request
  client.get("/channels")
rescue StandardError => e
  raise(ChannelError, e)
end