Class: NineOneOne::Notifier
- Inherits:
-
Object
- Object
- NineOneOne::Notifier
- Defined in:
- lib/nine_one_one/notifier.rb
Instance Method Summary collapse
- #emergency(description, source: Socket.gethostname, 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
- #resolve_emergency(dedup_key) ⇒ 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: Socket.gethostname, 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: Socket.gethostname, 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
21 22 23 24 25 26 27 |
# File 'lib/nine_one_one/notifier.rb', line 21 def emergency_service if config.send_pagers PagerDutyService.new(config.pager_duty_integration_key) else LogService.new(config.logger) end end |
#notification_service ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/nine_one_one/notifier.rb', line 29 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
17 18 19 |
# File 'lib/nine_one_one/notifier.rb', line 17 def notify() notification_service.notify() end |
#resolve_emergency(dedup_key) ⇒ Object
13 14 15 |
# File 'lib/nine_one_one/notifier.rb', line 13 def resolve_emergency(dedup_key) emergency_service.resolve_event(dedup_key) end |