failbot 2.5.4 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bae1044f6d88c6617750ffe63b606591880ebe5132d9714d2e4c9534e309962
4
- data.tar.gz: b1d80185dae5e664c049ed38583d25086d3659f517826c38912974d93fed32a6
3
+ metadata.gz: ef2b30021fd84983545c9fa374d030d9c1269d3ef51b778cf84d55fe96fde087
4
+ data.tar.gz: 998dde878c99c47177d03ff693625e05f1522009d84bf4e5f1a12a0fb398ad0e
5
5
  SHA512:
6
- metadata.gz: 8114032ca98920f4b902447d1b3c69b28ea6bfe14b52d8b1f431d0537295d5c565d9d8a17540afa72f00f439023bc711291542baa2044ada4cd6f547e9506c35
7
- data.tar.gz: f0040811958da514da048dd38af5de2cfd3978d6f036dc78c19b6080991b02bf69cca5b79f684ecc3a8c5b3885b577ecf77116fca445439f7ecfa06fbe5a3452
6
+ metadata.gz: 774ccebb4f0b04886309e32840d73f17b0278388a73aa6a15541870c791a832f68c767b140ed1d62527feff87ae880aedebf60e942946c103116103c32bda9be
7
+ data.tar.gz: 778c39eea60f8acdd0b53246401351e1373bf9386259fde67adfb86c0956baa8780fdda6afcf01f942ee6327aa8672390ec57d699e93ade429c8123b6f5ef3a6
@@ -142,6 +142,18 @@ module Failbot
142
142
  end
143
143
 
144
144
  populate_context_from_settings(settings)
145
+ @enable_timeout = false
146
+ if settings.key?("FAILBOT_TIMEOUT_MS")
147
+ @timeout_seconds = settings["FAILBOT_TIMEOUT_MS"].to_f / 1000
148
+ @enable_timeout = (@timeout_seconds > 0.0)
149
+ end
150
+
151
+ @connect_timeout_seconds = nil
152
+ if settings.key?("FAILBOT_CONNECT_TIMEOUT_MS")
153
+ @connect_timeout_seconds = settings["FAILBOT_CONNECT_TIMEOUT_MS"].to_f / 1000
154
+ # unset the value if it's not parsing to something valid
155
+ @connect_timeout_seconds = nil unless @connect_timeout_seconds > 0
156
+ end
145
157
 
146
158
  self.backend =
147
159
  case (name = settings["FAILBOT_BACKEND"])
@@ -152,7 +164,7 @@ module Failbot
152
164
  when "file"
153
165
  Failbot::FileBackend.new(settings["FAILBOT_BACKEND_FILE_PATH"])
154
166
  when "http"
155
- Failbot::HTTPBackend.new(URI(settings["FAILBOT_HAYSTACK_URL"]))
167
+ Failbot::HTTPBackend.new(URI(settings["FAILBOT_HAYSTACK_URL"]), @connect_timeout_seconds)
156
168
  when 'json'
157
169
  Failbot::JSONBackend.new(settings["FAILBOT_BACKEND_JSON_HOST"], settings["FAILBOT_BACKEND_JSON_PORT"])
158
170
  when 'console'
@@ -163,11 +175,6 @@ module Failbot
163
175
 
164
176
  @raise_errors = !settings["FAILBOT_RAISE"].to_s.empty?
165
177
  @report_errors = settings["FAILBOT_REPORT"] != "0"
166
- @enable_timeout = false
167
- if settings.key?("FAILBOT_TIMEOUT_MS")
168
- @timeout_seconds = settings["FAILBOT_TIMEOUT_MS"].to_f / 1000
169
- @enable_timeout = (@timeout_seconds != 0.0)
170
- end
171
178
 
172
179
  # allows overriding the 'app' value to send to single haystack bucket.
173
180
  # used primarily on ghe.io.
@@ -508,7 +515,8 @@ module Failbot
508
515
  def populate_context_from_settings(settings)
509
516
  settings.each do |key, value|
510
517
  if /\AFAILBOT_CONTEXT_(.+)\z/ =~ key
511
- context[0][$1.downcase] = value
518
+ key = $1.downcase
519
+ context[0][key] = value unless context[0][key]
512
520
  end
513
521
  end
514
522
  end
@@ -4,8 +4,10 @@ require 'json'
4
4
 
5
5
  module Failbot
6
6
  class Haystack
7
- def initialize(url)
7
+ attr_accessor :connect_timeout
8
+ def initialize(url, connect_timeout=nil)
8
9
  @url = url
10
+ @connect_timeout = connect_timeout
9
11
  end
10
12
 
11
13
  def user
@@ -50,6 +52,9 @@ module Failbot
50
52
  # use SSL if applicable
51
53
  http.use_ssl = true if @url.scheme == "https"
52
54
 
55
+ # Set the connect timeout if it was provided
56
+ http.open_timeout = @connect_timeout if @connect_timeout
57
+
53
58
  # push it through
54
59
  http.request(request)
55
60
  ensure
@@ -1,11 +1,12 @@
1
1
  module Failbot
2
2
  class HTTPBackend
3
- def initialize(url)
3
+ def initialize(url, connect_timeout = nil)
4
4
  if url.to_s.empty?
5
5
  raise ArgumentError, "FAILBOT_HAYSTACK_URL setting required."
6
6
  end
7
7
 
8
- @haystack = Failbot::Haystack.new(url)
8
+ @connect_timeout = connect_timeout
9
+ @haystack = Failbot::Haystack.new(url, connect_timeout)
9
10
  end
10
11
 
11
12
  def report(data)
@@ -19,5 +20,13 @@ module Failbot
19
20
  def ping
20
21
  @haystack.ping
21
22
  end
23
+
24
+ def connect_timeout
25
+ @haystack.connect_timeout
26
+ end
27
+
28
+ def connect_timeout=(timeout)
29
+ @haystack.connect_timeout = timeout
30
+ end
22
31
  end
23
32
  end
@@ -1,3 +1,3 @@
1
1
  module Failbot
2
- VERSION = "2.5.4"
2
+ VERSION = "2.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: failbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 2.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@rtomayko"
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-08-17 00:00:00.000000000 Z
13
+ date: 2020-09-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake