Skip to content

Commit a488d0b

Browse files
stephencelisdefunkt
authored andcommitted
Additional Hoptoad configuration support.
1 parent 37385f1 commit a488d0b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/resque/failure/hoptoad.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ class Hoptoad < Base
2626
INPUT_FORMAT = /^([^:]+):(\d+)(?::in `([^']+)')?$/
2727

2828
class << self
29-
attr_accessor :secure, :api_key, :proxy_host, :proxy_port
29+
attr_accessor :secure, :api_key
30+
attr_accessor :proxy_host, :proxy_port, :proxy_user, :proxy_pass
3031
attr_accessor :server_environment
32+
attr_accessor :host, :port
33+
attr_accessor :http_read_timeout, :http_open_timeout
3134
end
3235

3336
def self.count
@@ -43,17 +46,20 @@ def self.configure
4346

4447
def save
4548
http = use_ssl? ? :https : :http
46-
url = URI.parse("#{http}://hoptoadapp.com/notifier_api/v2/notices")
49+
host = self.class.host || 'hoptoadapp.com'
50+
port = self.class.port
51+
url = URI.parse("#{http}://#{host}:#{port}/notifier_api/v2/notices/")
4752

48-
request = Net::HTTP::Proxy(self.class.proxy_host, self.class.proxy_port)
53+
request = Net::HTTP::Proxy self.class.proxy_host, self.class.proxy_port,
54+
self.class.proxy_user, self.class.proxy_pass
4955
http = request.new(url.host, url.port)
5056
headers = {
5157
'Content-type' => 'text/xml',
5258
'Accept' => 'text/xml, application/xml'
5359
}
5460

55-
http.read_timeout = 5 # seconds
56-
http.open_timeout = 2 # seconds
61+
http.read_timeout = self.class.http_read_timeout || 5 # seconds
62+
http.open_timeout = self.class.http_open_timeout || 2 # seconds
5763

5864
http.use_ssl = use_ssl?
5965

0 commit comments

Comments
 (0)