Class: NineOneOne::Notifier
- Inherits:
-
Object
- Object
- NineOneOne::Notifier
- Defined in:
- lib/nine_one_one/notifier.rb
Instance Method Summary collapse
- #emergency(description, source, dedup_key: nil, severity: PagerDutyService::HIGH_URGENCY_ERROR, details_hash: nil) ⇒ Object
- #emergency_service ⇒ Object
-
#initialize(config) ⇒ Notifier
constructor
A new instance of Notifier.
- #notification_service ⇒ Object
- #notify(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ Notifier
Returns a new instance of Notifier.
3 4 5 |
# File 'lib/nine_one_one/notifier.rb', line 3 def initialize(config) @config = config end |
Instance Method Details
#emergency(description, source, dedup_key: nil, severity: PagerDutyService::HIGH_URGENCY_ERROR, details_hash: nil) ⇒ Object
7 8 9 10 11 |
# File 'lib/nine_one_one/notifier.rb', line 7 def emergency(description, source, dedup_key: nil, severity: PagerDutyService::HIGH_URGENCY_ERROR, details_hash: nil) emergency_service.trigger_event(description, source: source, dedup_key: dedup_key, severity: severity, details_hash: details_hash) end |
#emergency_service ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/nine_one_one/notifier.rb', line 17 def emergency_service if config.send_pagers PagerDutyService.new(config.pager_duty_integration_key) else LogService.new(config.logger) end end |
#notification_service ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/nine_one_one/notifier.rb', line 25 def notification_service if config.slack_enabled SlackService.new(config.slack_webhook_url, username: config.slack_username, channel: config.slack_channel) else LogService.new(config.logger) end end |
#notify(message) ⇒ Object
13 14 15 |
# File 'lib/nine_one_one/notifier.rb', line 13 def notify() notification_service.notify() end |