This repository was archived by the owner on Mar 27, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -8,27 +8,23 @@ class UrlMonitor
8
8
attr_reader :test_result
9
9
attr_reader :url
10
10
attr_reader :connection
11
- attr_reader :retry_limit
12
- attr_reader :connect_timeout
11
+ attr_reader :options
13
12
14
13
def init ( monitor )
14
+ raise "A url must be provided for url_monitor in #{ monitor [ :monitor ] } monitor" if monitor [ :url ] . nil?
15
15
@url = monitor [ :url ]
16
- @retry_limit = monitor [ :retry_limit ]
17
- @connect_timeout = monitor [ :connect_timeout ]
18
- raise "A url must be provided for url_monitor in #{ monitor [ :monitor ] } monitor" if @url . nil?
19
- end
20
-
21
- def test_command?
22
16
@connection = Excon . new ( @url )
23
- options = {
17
+ @ options = {
24
18
expects : [ 200 , 301 , 302 ] ,
25
19
method : :get ,
26
20
idempotent : true
27
21
}
22
+ @options [ :retry_limit ] = monitor [ :retry_limit ] || 3
23
+ @options [ :connect_timeout ] = monitor [ :connect_timeout ] || 60
24
+ end
28
25
29
- options [ :retry_limit ] = @retry_limit || 3
30
- options [ :connect_timeout ] = @connect_timeout || 60
31
- response = @connection . request ( options )
26
+ def test_command?
27
+ response = @connection . request ( @options )
32
28
@test_result = { "HTTP GET Request to #{ @url } " => response . status }
33
29
return true
34
30
rescue => e
You can’t perform that action at this time.
0 commit comments