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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/koa-utils/health-check.rb +19 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da64a6c984e70649f056fdca9bc74d52615d5110
4
- data.tar.gz: 48401dbc5f8681ac507181cd8d8834a284908356
3
+ metadata.gz: d170b83a94ecfec90ed98bc44349c3ee8d2793a8
4
+ data.tar.gz: 7c9cfc7066216e885c24c6e0f155e6d2d10f4444
5
5
  SHA512:
6
- metadata.gz: 995ced7acec62d1f14e9ea88e06021166e9c387c5c58eb133a2180983b969ae64664b59d927a3daf1f572ad184dac52c48b8ed071f62cc9247af3b4e5569ef6b
7
- data.tar.gz: 97f63ce149300af439bf239429a49cf4dbd31c249324f84ba3c39568835371c4a8086407f2f537e8e814bd270029187f172c57e48feb829a52bbe42374a3cddc
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.3
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