health-reporter 0.0.2 → 0.0.3
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.md +42 -1
- data/lib/health_reporter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155d97c5b4cc48d064e2d0c3ba40c19094a6c700
|
4
|
+
data.tar.gz: 2e1bc68f9c30819cd1fd586ce1a7f01552e038dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 049f9b1956fccdd9d144bcb087e159b8555e2e861d239a0f32929209ce65c88426586fa5d2b18647656f02e50e4be0e08e1ba1d426d30427f36b6dd007bdd9a8
|
7
|
+
data.tar.gz: 1a538e5844bff5fd7c8ac3a0e29d1814e86884ffb03f040959dfdc731944865e64960237453c9f10ef6d3eb73581cec4f276980e0f601c42f0d9b836373bdb46
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# HealthReporter
|
2
2
|
|
3
|
+
The HealthReporter gem makes the caching of health check requests on services easy. Simiply register a lambda returning true/false that determines if the service is healthy or not. The HealthReporter caches the result for future requests using a TTL value. If the cache is still valid it will not use the lambda to determine service health.
|
3
4
|
|
4
5
|
## Installation
|
5
6
|
|
@@ -33,7 +34,47 @@ docker-compose run --rm health-reporter bundle exec rspec -cfd spec/*
|
|
33
34
|
|
34
35
|
## Usage
|
35
36
|
|
36
|
-
|
37
|
+
### Overview
|
38
|
+
|
39
|
+
Out of the box you can simply call it as follows with the preconfigured always true self-check lambda:
|
40
|
+
```ruby
|
41
|
+
require 'health_reporter'
|
42
|
+
HealthReporter.healthy?
|
43
|
+
=> true
|
44
|
+
```
|
45
|
+
|
46
|
+
The default values can be overridden as follow:
|
47
|
+
```ruby
|
48
|
+
require 'health_reporter'
|
49
|
+
HealthReporter.self_test = lambda{ false }
|
50
|
+
HealthReporter.healthy_cache_ttl = 60
|
51
|
+
HealthReporter.unhealthy_cache_ttl = 30
|
52
|
+
HealthReporter.healthy?
|
53
|
+
=> false
|
54
|
+
```
|
55
|
+
|
56
|
+
### Configuration on startup
|
57
|
+
|
58
|
+
First it is set up somewhere in your service startup (config.ru) where you configure how it determines health:
|
59
|
+
```ruby
|
60
|
+
require 'health_reporter'
|
61
|
+
HealthReporter.self_test = lambda{ false }
|
62
|
+
HealthReporter.healthy_cache_ttl = 60
|
63
|
+
HealthReporter.unhealthy_cache_ttl = 30
|
64
|
+
```
|
65
|
+
|
66
|
+
### Health checking via an endpoint
|
67
|
+
|
68
|
+
In the controller/model of the health check you simply call the following and based on the boolean return respond with 200 or 500 for other services to see this service health:
|
69
|
+
```ruby
|
70
|
+
require 'health_reporter'
|
71
|
+
HealthReporter.healthy?
|
72
|
+
=> false
|
73
|
+
```
|
74
|
+
|
75
|
+
## Future
|
76
|
+
|
77
|
+
### Add dependency registration and calling
|
37
78
|
|
38
79
|
## Contributing
|
39
80
|
|