Sha256: 90e6a0f6cefac89e5580099fdd6643347917c80e1135a7b3d65d66f2ab231359

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

require 'pusher'

module OkComputer
  class PusherCheck < Check
    ChannelError = Class.new(StandardError)

    attr_accessor :client

    def initialize(client: nil, app_id: nil, app_key: nil, app_secret: nil, app_cluster: nil)
      client ||= Pusher::Client.new(
        app_id: app_id,
        key: app_key,
        secret: app_secret,
        cluster: app_cluster,
        use_tls: true
      )

      self.client = client
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
okcomputer-checks-1.1.1 lib/ok_computer/checks/pusher_check.rb
okcomputer-checks-1.1.0 lib/ok_computer/checks/pusher_check.rb
okcomputer-checks-1.0.0 lib/ok_computer/checks/pusher_check.rb