Class: Failbot::Haystack
- Inherits:
-
Object
- Object
- Failbot::Haystack
- Defined in:
- lib/failbot/haystack.rb
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#rw_timeout ⇒ Object
Returns the value of attribute rw_timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url, connect_timeout = nil, timeout_seconds = nil) ⇒ Haystack
constructor
A new instance of Haystack.
- #password ⇒ Object
- #ping ⇒ Object
- #send_data(data) ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(url, connect_timeout = nil, timeout_seconds = nil) ⇒ Haystack
Returns a new instance of Haystack.
8 9 10 11 12 |
# File 'lib/failbot/haystack.rb', line 8 def initialize(url, connect_timeout=nil, timeout_seconds=nil) @url = url @connect_timeout = connect_timeout @rw_timeout = timeout_seconds - @connect_timeout.to_f if timeout_seconds end |
Instance Attribute Details
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
7 8 9 |
# File 'lib/failbot/haystack.rb', line 7 def connect_timeout @connect_timeout end |
#rw_timeout ⇒ Object
Returns the value of attribute rw_timeout.
7 8 9 |
# File 'lib/failbot/haystack.rb', line 7 def rw_timeout @rw_timeout end |
Class Method Details
Instance Method Details
#password ⇒ Object
18 19 20 |
# File 'lib/failbot/haystack.rb', line 18 def password @url.password end |
#ping ⇒ Object
37 38 39 40 41 |
# File 'lib/failbot/haystack.rb', line 37 def ping request = Net::HTTP::Head.new('/') response = send_request(request) raise StandardError, "haystack returned #{response.code}" unless response.code == "200" end |
#send_data(data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/failbot/haystack.rb', line 22 def send_data(data) # make a post post = Net::HTTP::Post.new(@url.path) post.set_form_data('json' => data.to_json) response = send_request(post) # Raise if the exception doesn't make it to Haystack, ensures the failure # is logged raise StandardError, "couldn't send exception to Haystack: #{response.code} #{response.}" unless response.code == "201" end |
#user ⇒ Object
14 15 16 |
# File 'lib/failbot/haystack.rb', line 14 def user @url.user || "failbot" end |