Class: Findbug::Alerts::Channels::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/findbug/alerts/channels/base.rb

Overview

Base is the abstract base class for alert channels.

CHANNEL PATTERN

Each channel implements:

  1. #initialize(config) - Receive channel configuration

  2. #send_alert(error_event) - Send the alert

This pattern allows adding new channels easily:

class PagerDuty < Base
  def send_alert(error_event)
    # Call PagerDuty API
  end
end

Direct Known Subclasses

Discord, Email, Slack, Webhook

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



26
27
28
# File 'lib/findbug/alerts/channels/base.rb', line 26

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



24
25
26
# File 'lib/findbug/alerts/channels/base.rb', line 24

def config
  @config
end

Instance Method Details

#send_alert(error_event) ⇒ Object

Send an alert for an error event

Parameters:

  • error_event (ErrorEvent)

    the error to alert about

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/findbug/alerts/channels/base.rb', line 34

def send_alert(error_event)
  raise NotImplementedError, "#{self.class} must implement #send_alert"
end