rails-healthcheck 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f365d0578746bf65bd75b360fbf3af46e3cba738a6eb9c9a3e88df133efee7c
4
- data.tar.gz: e7c5d26b27e0f939a07e20a70f69dcac975ac9efc1d3ee06ec12d7a81f2f22dc
3
+ metadata.gz: cc601f25aec17caeb2d47054f8ded7aebae50eca08dc0e3261990ea71f14d1b9
4
+ data.tar.gz: c52256a6152ecbf4b35a3d10678d471f1b39310f6db9c7738f5d08f7c687528a
5
5
  SHA512:
6
- metadata.gz: 8d1d0412ade72f8d0a06d9ce2160164109e0d21bbe3c7cf13c1798267ecf59746581671602b552d6d023514e70c435c986749b15575844b328e2403f23ab0230
7
- data.tar.gz: 400bee85de2479a5ae575a54c085c597fee2b46709c0cfa1066d628d17bf46d511a92563834ae0007613bad885130895555b38ea0d2df2c61e2db8aa4e113d72
6
+ metadata.gz: 5f6f1011049080ff2cceba13fb37fd7ced41a8f455abcd30b84591972e448a9c69cd934768efbea731261273367c605ae23895cbb2135f4e4cab7a2042eab300
7
+ data.tar.gz: 6537e333c8c8b53153dbd23639ad32ed2dd088292ba70590de4b845dbcdf7013cad1a106cdb09c16e01f22bda4a3d529ce2f29c63b10b62e20b485c44fcd5ca9
@@ -4,36 +4,28 @@ require 'action_controller/railtie'
4
4
  module Healthcheck
5
5
  class HealthchecksController < ActionController::Base
6
6
  def check
7
- execute
8
- errored? ? error : success
9
- end
10
-
11
- private
7
+ checker = Healthcheck.check
8
+ return head Healthcheck.configuration.success unless checker.errored?
12
9
 
13
- def execute
14
- checker.check
10
+ verbose? ? verbose_error(checker) : head_error
15
11
  end
16
12
 
17
- def errored?
18
- checker.errored?
19
- end
13
+ private
20
14
 
21
- def checker
22
- @checker ||= Healthcheck::Checker.new
15
+ def head_error
16
+ head(Healthcheck.configuration.error)
23
17
  end
24
18
 
25
- def success
26
- head Healthcheck.configuration.success
19
+ def verbose_error(checker)
20
+ render status: Healthcheck.configuration.error,
21
+ json: {
22
+ code: Healthcheck.configuration.error,
23
+ errors: checker.errors.as_json
24
+ }
27
25
  end
28
26
 
29
- def error
30
- return head(Healthcheck.configuration.error) unless Healthcheck.configuration.verbose
31
-
32
- render json: {
33
- code: Healthcheck.configuration.error,
34
- errors: checker.errors.as_json
35
- },
36
- status: Healthcheck.configuration.error
27
+ def verbose?
28
+ Healthcheck.configuration.verbose
37
29
  end
38
30
  end
39
31
  end
@@ -9,7 +9,10 @@ module Healthcheck
9
9
  end
10
10
 
11
11
  def check
12
- Healthcheck.configuration.checks.map { |c| Thread.new { execute(c) } }.each(&:join)
12
+ Healthcheck.configuration
13
+ .checks
14
+ .map { |c| Thread.new { execute(c) } }
15
+ .each(&:join)
13
16
  end
14
17
 
15
18
  def errored?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Healthcheck
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
5
5
  end
data/lib/healthcheck.rb CHANGED
@@ -22,4 +22,8 @@ module Healthcheck
22
22
  def routes(router)
23
23
  Healthcheck::Router.mount(router)
24
24
  end
25
+
26
+ def check
27
+ Healthcheck::Checker.new.tap(&:check)
28
+ end
25
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-healthcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - linqueta