koa-utils 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/koa-utils/health-check.rb +19 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d170b83a94ecfec90ed98bc44349c3ee8d2793a8
|
4
|
+
data.tar.gz: 7c9cfc7066216e885c24c6e0f155e6d2d10f4444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c079c7f0ff1eddabf5084834a772292907b111a02fbfa5cc64cbc77781b3b7e8f2452e23f307aff64913b3629dc1ffa6248aaf1e1320bf0fcfd7a2c4b7f18e61
|
7
|
+
data.tar.gz: 9a93743f9e99f049e1a1102572717c420c511aed18534dda5efaaf43e12e5e02e68f91aae0965bc2da68fefa899015f80affbce75b13499437041e2d62182942
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
if !defined?(ActiveRecord)
|
5
|
+
raise("KOAUtils::HealthCheck expects ActiveRecord to be defined.")
|
6
|
+
end
|
7
|
+
|
8
|
+
class KOAUtils::HealthCheck
|
9
|
+
def self.call(env)
|
10
|
+
begin
|
11
|
+
Timeout::timeout(2) do
|
12
|
+
ActiveRecord::Base.connection.execute("SELECT * from users limit 1")
|
13
|
+
end
|
14
|
+
rescue => e
|
15
|
+
return [500, {"Content-Type" => "text/json"}, [JSON.dump({error: e.message})]]
|
16
|
+
end
|
17
|
+
[200, {"Content-Type" => "text/json"}, [JSON.dump({info: Time.now})]]
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koa-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Rykwalder
|
@@ -16,6 +16,7 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- lib/koa-utils/health-check.rb
|
19
20
|
- lib/koa-utils/logger.rb
|
20
21
|
- lib/koa-utils.rb
|
21
22
|
homepage: http://github.com/albumatic
|