Sha256: 63b2501896760a670662533bd6752d04e9d44d40bb318ea7a1da027149382fb8

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

#!/usr/bin/env ruby

require 'ostruct'

module Flapjack
  class Notifier
   
    attr_reader :recipients, :log, :notifiers
  
    def initialize(opts={})
      @log = opts[:logger]
      raise "you have to specify a logger" unless @log
      @recipients = (opts[:recipients] || [])
      
      @notifiers = []
      if opts[:notifiers]
        opts[:notifiers].each do |n|
          @notifiers << n
          @log.info("using the #{n.class.to_s.split("::").last} notifier")
        end
      else
        @log.warning("there are no notifiers")
      end
    end
    
    def notify!(result)
      @notifiers.each do |n|
        @recipients.each do |recipient|
          @log.info("Notifying #{recipient.name} via #{n.class} about check #{result.id}")
          n.notify(:result => result, :who => recipient)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flapjack-0.4.11 lib/flapjack/notifier.rb
flapjack-0.4.10 lib/flapjack/notifier.rb