health_bit 0.1.7 → 0.1.8
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/Gemfile.lock +1 -1
- data/README.md +48 -7
- data/lib/health_bit.rb +6 -0
- data/lib/health_bit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b89365fc234404da475087af408d01f927f8c58a0e41eadbe3d0f5bf172c551
|
4
|
+
data.tar.gz: 17a35b4d08227b12eb7d787843d760b01bd2d9f53d36eecb6b00d3811b689a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e6441577cb24561a366b674978d501b86ae641ef40cdcccbea1054651a5aad1c3dd9d59a2f2b4cce34d3ce4f22fac8668265c87fbaa92771e9f61d1e522311f
|
7
|
+
data.tar.gz: 9e86554bad55338dcd40a5ca192e0aee79753936ad52935649a46980f66aac092359642cc41f53eadb5a55d8b61f6e895c181ee6206a4490266f02a3055d7620
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,11 +22,18 @@ Key differences:
|
|
22
22
|
* [Add Checks](#add-checks)
|
23
23
|
* [Add a Route](#add-a-route)
|
24
24
|
* [Password Protection](#password-protection)
|
25
|
+
* [Multiple endpoints](#multiple-endpoints)
|
26
|
+
|
27
|
+
## Check Examples
|
28
|
+
|
25
29
|
* [Database check](#database-check)
|
26
30
|
* [Redis check](#redis-check)
|
31
|
+
* [Sidekiq check](#sidekiq-check)
|
27
32
|
* [Rails cache check](#rails-cache-check)
|
28
33
|
* [Elasticsearch check](#elasticsearch-check)
|
29
|
-
* [
|
34
|
+
* [RabbitMQ check](#rabbitmq-check)
|
35
|
+
* [HTTP check](#http-check)
|
36
|
+
* [ClickHouse check](#clickhouse-check)
|
30
37
|
|
31
38
|
## Installation
|
32
39
|
|
@@ -40,8 +47,9 @@ gem 'health_bit'
|
|
40
47
|
|
41
48
|
```ruby
|
42
49
|
# config/initializers/health_bit.rb
|
43
|
-
|
50
|
+
|
44
51
|
HealthBit.configure do |c|
|
52
|
+
# DEFAULT SETTINGS ARE SHOWN BELOW
|
45
53
|
c.success_text = '%<count>d checks passed 🎉'
|
46
54
|
c.headers = {
|
47
55
|
'Content-Type' => 'text/plain;charset=utf-8',
|
@@ -87,9 +95,10 @@ HealthBit.add('Docker service') do
|
|
87
95
|
end
|
88
96
|
|
89
97
|
# The Check can be added as an object responding to a call
|
98
|
+
# (to be able to test your check)
|
90
99
|
class Covid19Check
|
91
100
|
def self.call
|
92
|
-
|
101
|
+
false
|
93
102
|
end
|
94
103
|
end
|
95
104
|
|
@@ -112,14 +121,14 @@ end
|
|
112
121
|
## Password Protection
|
113
122
|
|
114
123
|
Since the gem is a common rack application, you can add any rack
|
115
|
-
middleware. Below is an example with HTTP-auth for the Rails.
|
124
|
+
middleware to it. Below is an example with HTTP-auth for the Rails.
|
116
125
|
|
117
126
|
```ruby
|
118
127
|
# config/routes.rb
|
119
128
|
|
120
129
|
Rails.application.routes.draw do
|
121
130
|
HealthBit.rack.use Rack::Auth::Basic do |username, password|
|
122
|
-
ActiveSupport::SecurityUtils.secure_compare(Digest::SHA256.hexdigest(username),
|
131
|
+
ActiveSupport::SecurityUtils.secure_compare(Digest::SHA256.hexdigest(username), Digest::SHA256.hexdigest('user')) & ActiveSupport::SecurityUtils.secure_compare(Digest::SHA256.hexdigest(password), Digest::SHA256.hexdigest('password'))
|
123
132
|
end
|
124
133
|
|
125
134
|
mount HealthBit.rack => '/health'
|
@@ -138,7 +147,15 @@ end
|
|
138
147
|
|
139
148
|
```ruby
|
140
149
|
HealthBit.add('Redis') do
|
141
|
-
Redis.current.ping == 'PONG'
|
150
|
+
Redis.current.ping == 'PONG'
|
151
|
+
end
|
152
|
+
```
|
153
|
+
|
154
|
+
## Sidekiq check
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
HealthBit.add('Sidekiq') do
|
158
|
+
Sidekiq.redis(&:ping) == 'PONG'
|
142
159
|
end
|
143
160
|
```
|
144
161
|
|
@@ -158,11 +175,35 @@ HealthBit.add('Elasticsearch') do
|
|
158
175
|
end
|
159
176
|
```
|
160
177
|
|
178
|
+
## RabbitMQ check
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
HealthBit.add('RabbitMQ') do
|
182
|
+
Bunny::Connection.connect(&:connection)
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
## HTTP check
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
HealthBit.add('HTTP check') do
|
190
|
+
Net::HTTP.new('www.example.com', 80).request_get('/').kind_of?(Net::HTTPSuccess)
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
## ClickHouse check
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
HealthBit.add('ClickHouse') do
|
198
|
+
ClickHouse.connection.ping
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
161
202
|
## Multiple endpoints
|
162
203
|
|
163
204
|
Sometimes you have to add several health check endpoints. Let's say
|
164
205
|
you have to check the docker container health and the health
|
165
|
-
of your application as a whole. Below is an example for
|
206
|
+
of your application as a whole. Below is an example for the Rails.
|
166
207
|
|
167
208
|
```ruby
|
168
209
|
# config/initializers/health_bit.rb
|
data/lib/health_bit.rb
CHANGED
data/lib/health_bit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: health_bit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksandr Shylau
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|