Class: Flapjack::Gateways::Email
- Inherits:
-
Object
- Object
- Flapjack::Gateways::Email
- Includes:
- Utility
- Defined in:
- lib/flapjack/gateways/email.rb
Instance Attribute Summary collapse
-
#sent ⇒ Object
Returns the value of attribute sent.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Email
constructor
A new instance of Email.
- #start ⇒ Object
- #stop_type ⇒ Object
Methods included from Utility
#hashify, #load_template, #local_timezone, #relative_time_ago, #remove_utc_offset, #stringify, #symbolize, #time_period_in_words, #truncate
Constructor Details
#initialize(opts = {}) ⇒ Email
Returns a new instance of Email.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flapjack/gateways/email.rb', line 27 def initialize(opts = {}) @lock = opts[:lock] @config = opts[:config] # TODO support for config reloading @queue = Flapjack::RecordQueue.new(@config['queue'] || 'email_notifications', Flapjack::Data::Alert) if @smtp_config = @config['smtp_config'] @host = @smtp_config['host'] || 'localhost' @port = @smtp_config['port'] || 25 # NB: needs testing if @smtp_config['authentication'] && @smtp_config['username'] && @smtp_config['password'] @auth = {:authentication => @smtp_config['authentication'], :username => @smtp_config['username'], :password => @smtp_config['password'], :enable_starttls_auto => true } end else @host = 'localhost' @port = 25 end @fqdn = `/bin/hostname -f`.chomp @sent = 0 end |
Instance Attribute Details
#sent ⇒ Object
Returns the value of attribute sent.
25 26 27 |
# File 'lib/flapjack/gateways/email.rb', line 25 def sent @sent end |
Instance Method Details
#start ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/flapjack/gateways/email.rb', line 59 def start Flapjack.logger.debug("new email gateway pikelet with the following options: #{@config.inspect}") begin Zermelo.redis = Flapjack.redis loop do @lock.synchronize do @queue.foreach {|alert| handle_alert(alert) } end @queue.wait end ensure Flapjack.redis.quit end end |
#stop_type ⇒ Object
77 78 79 |
# File 'lib/flapjack/gateways/email.rb', line 77 def stop_type :exception end |