okcomputer 1.11.1 → 1.12.0
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 +4 -4
- data/README.markdown +29 -0
- data/Rakefile +10 -5
- data/app/controllers/ok_computer/ok_computer_controller.rb +2 -2
- data/lib/ok_computer/built_in_checks/ping_check.rb +52 -0
- data/lib/ok_computer/legacy_rails_controller_support.rb +1 -1
- data/lib/ok_computer/version.rb +1 -1
- data/lib/okcomputer.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f34f802639366baa476811ef5887698d421430
|
4
|
+
data.tar.gz: a561e25ff0338f38ab6f74f992b0fcde158f1a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b90dc5648bade933b9cc58c45db4e71c434e6920b3c3a3cc9ac78c1238b3b8ad1c3d49ce380533faee081ab7a055dc19547a70176a8fe3e7e37bc95c2df65918
|
7
|
+
data.tar.gz: 57dea05e4612d62026a7aee1bc3ec6bdffc85666a67e298332bfbab015da014218480fc76b5b9ca7742fb47cf108e91fc842cf8a33eb738ff4097e19c0e12f2a
|
data/README.markdown
CHANGED
@@ -15,6 +15,13 @@ OK Computer][blog].
|
|
15
15
|
|
16
16
|
[blog]:http://pulse.sportngin.com/news_article/show/267646?referrer_id=543230
|
17
17
|
|
18
|
+
OkComputer currently supports the following Rails versions:
|
19
|
+
|
20
|
+
* 3.2
|
21
|
+
* 4.1
|
22
|
+
* 4.2
|
23
|
+
* 5.0
|
24
|
+
|
18
25
|
#### Not using Rails?
|
19
26
|
|
20
27
|
If you use [Grape] instead of Rails, check out [okcomputer-grape].
|
@@ -180,6 +187,28 @@ If you'd like to intentionally count OkComputer requests in your NewRelic analyt
|
|
180
187
|
OkComputer.analytics_ignore = false
|
181
188
|
```
|
182
189
|
|
190
|
+
## Development
|
191
|
+
|
192
|
+
### Setup
|
193
|
+
|
194
|
+
```plaintext
|
195
|
+
$ bundle install
|
196
|
+
```
|
197
|
+
|
198
|
+
### Running the test suite
|
199
|
+
|
200
|
+
OkComputer tests are written with [RSpec](http://rspec.info/).
|
201
|
+
|
202
|
+
To run the full test suite:
|
203
|
+
|
204
|
+
```plaintext
|
205
|
+
$ rake spec
|
206
|
+
```
|
207
|
+
|
208
|
+
You may also use the environment variable `RAILS_VERSION` with one
|
209
|
+
of the supported versions of Rails (found at the top of this file) to
|
210
|
+
bundle and run the tests with a specific version of Rails.
|
211
|
+
|
183
212
|
## Contributing
|
184
213
|
|
185
214
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -9,13 +9,18 @@ Bundler::GemHelper.install_tasks
|
|
9
9
|
|
10
10
|
task :default => :spec
|
11
11
|
|
12
|
-
|
12
|
+
begin
|
13
|
+
require "rspec/core/rake_task"
|
13
14
|
|
14
|
-
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
16
|
+
puts "Testing with Rails #{ENV["RAILS_VERSION"]}..." if ENV["RAILS_VERSION"]
|
17
|
+
end
|
15
18
|
|
16
|
-
namespace :spec do
|
17
|
-
|
18
|
-
|
19
|
+
namespace :spec do
|
20
|
+
RSpec::Core::RakeTask.new(:docs) do |t|
|
21
|
+
t.rspec_opts = ["--format doc"]
|
22
|
+
end
|
19
23
|
end
|
24
|
+
rescue LoadError
|
20
25
|
end
|
21
26
|
|
@@ -13,7 +13,7 @@ module OkComputer
|
|
13
13
|
|
14
14
|
rescue_from OkComputer::Registry::CheckNotFound do |e|
|
15
15
|
respond_to do |f|
|
16
|
-
f.any(:text, :html) { render plain: e.message, status: :not_found }
|
16
|
+
f.any(:text, :html) { render plain: e.message, status: :not_found, content_type: 'text/plain' }
|
17
17
|
f.json { render json: { error: e.message }, status: :not_found }
|
18
18
|
end
|
19
19
|
end
|
@@ -36,7 +36,7 @@ module OkComputer
|
|
36
36
|
|
37
37
|
def respond(data, status)
|
38
38
|
respond_to do |format|
|
39
|
-
format.any(:text, :html) { render plain: data, status: status }
|
39
|
+
format.any(:text, :html) { render plain: data, status: status, content_type: 'text/plain' }
|
40
40
|
format.json { render json: data, status: status }
|
41
41
|
end
|
42
42
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module OkComputer
|
2
|
+
# Performs a health check by making a TCPSocket request to the host and port.
|
3
|
+
# A non-error response is considered passing.
|
4
|
+
class PingCheck < Check
|
5
|
+
ConnectionFailed = Class.new(StandardError)
|
6
|
+
|
7
|
+
attr_accessor :host, :port, :request_timeout
|
8
|
+
|
9
|
+
# Public: Initialize a new ping check.
|
10
|
+
#
|
11
|
+
# host - the hostname
|
12
|
+
# port - the port, as a string
|
13
|
+
# request_timeout - How long to wait to connect before timing out. Defaults to 5 seconds.
|
14
|
+
def initialize(host, port, request_timeout = 5)
|
15
|
+
raise ArgumentError if host.blank? || port.blank?
|
16
|
+
self.host = host
|
17
|
+
self.port = port
|
18
|
+
self.request_timeout = request_timeout.to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: Return the status of the Ping check
|
22
|
+
def check
|
23
|
+
tcp_socket_request
|
24
|
+
mark_message "Ping check to #{host}:#{port} successful"
|
25
|
+
rescue => e
|
26
|
+
mark_message "Error: '#{e}'"
|
27
|
+
mark_failure
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Returns true if the request was successful.
|
33
|
+
# Otherwise raises a PingCheck::ConnectionFailed error.
|
34
|
+
def tcp_socket_request
|
35
|
+
Timeout.timeout(request_timeout) do
|
36
|
+
s = TCPSocket.new(host, port)
|
37
|
+
s.close
|
38
|
+
end
|
39
|
+
rescue Errno::ECONNREFUSED => e
|
40
|
+
addl_message = "#{host} is not accepting connections on port #{port}: "
|
41
|
+
raise ConnectionFailed, addl_message + e.message
|
42
|
+
rescue SocketError => e
|
43
|
+
addl_message = "connection to #{host} on port #{port} failed with '#{e.message}': "
|
44
|
+
raise ConnectionFailed, addl_message + e.message
|
45
|
+
rescue TimeoutError => e
|
46
|
+
addl_message = "#{host} did not respond on port #{port} within #{request_timeout} seconds: "
|
47
|
+
raise ConnectionFailed, addl_message + e.message
|
48
|
+
rescue => e
|
49
|
+
raise ConnectionFailed, e
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/ok_computer/version.rb
CHANGED
data/lib/okcomputer.rb
CHANGED
@@ -20,6 +20,7 @@ require "ok_computer/built_in_checks/mongoid_check"
|
|
20
20
|
require "ok_computer/built_in_checks/neo4j_check"
|
21
21
|
require "ok_computer/built_in_checks/mongoid_replica_set_check"
|
22
22
|
require "ok_computer/built_in_checks/optional_check"
|
23
|
+
require "ok_computer/built_in_checks/ping_check"
|
23
24
|
require "ok_computer/built_in_checks/rabbitmq_check"
|
24
25
|
require "ok_computer/built_in_checks/redis_check"
|
25
26
|
require "ok_computer/built_in_checks/resque_backed_up_check"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okcomputer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sqlite3
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/ok_computer/built_in_checks/mongoid_replica_set_check.rb
|
85
85
|
- lib/ok_computer/built_in_checks/neo4j_check.rb
|
86
86
|
- lib/ok_computer/built_in_checks/optional_check.rb
|
87
|
+
- lib/ok_computer/built_in_checks/ping_check.rb
|
87
88
|
- lib/ok_computer/built_in_checks/rabbitmq_check.rb
|
88
89
|
- lib/ok_computer/built_in_checks/redis_check.rb
|
89
90
|
- lib/ok_computer/built_in_checks/resque_backed_up_check.rb
|