Class: EY::Stonith::AwsmNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ey_stonith/awsm_notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, instance_id, token, params) ⇒ AwsmNotifier

Returns a new instance of AwsmNotifier.



8
9
10
# File 'lib/ey_stonith/awsm_notifier.rb', line 8

def initialize(uri, instance_id, token, params)
  @uri, @instance_id, @token, @params = uri, instance_id, token, params
end

Instance Method Details

#notify(success, unreachable) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ey_stonith/awsm_notifier.rb', line 12

def notify(success, unreachable)
  Stonith.logger.info "Attempting to notify #@uri that master is down."

  code, body = do_request

  case code
  when 200...300
    if body.empty?
      success.call {}
    else
      success.call JSON.parse(body)
    end
  else
    unreachable.call
  end
rescue StandardError, Timeout::Error
  unreachable.call
end