Class: Flapjack::Gateways::Slack
- Inherits:
-
Object
- Object
- Flapjack::Gateways::Slack
- Includes:
- Utility
- Defined in:
- lib/flapjack/gateways/slack.rb
Instance Attribute Summary collapse
-
#sent ⇒ Object
Returns the value of attribute sent.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Slack
constructor
A new instance of Slack.
- #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 = {}) ⇒ Slack
Returns a new instance of Slack.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flapjack/gateways/slack.rb', line 20 def initialize(opts = {}) @lock = opts[:lock] @config = opts[:config] # TODO support for config reloading @queue = Flapjack::RecordQueue.new(@config['queue'] || 'slack_notifications', Flapjack::Data::Alert) @sent = 0 end |
Instance Attribute Details
#sent ⇒ Object
Returns the value of attribute sent.
18 19 20 |
# File 'lib/flapjack/gateways/slack.rb', line 18 def sent @sent end |
Instance Method Details
#start ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/flapjack/gateways/slack.rb', line 31 def start Flapjack.logger.debug("new slack 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
49 50 51 |
# File 'lib/flapjack/gateways/slack.rb', line 49 def stop_type :exception end |