on_strum-healthcheck 0.1.0 → 0.3.0

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: 49506d15af7f2a697b464a09f7e8ee603545714e0461ad9e58438260fc90a19f
4
- data.tar.gz: dbacd0cc9ed4983e964974ca669355f76173992aec19ab2e529a91dafea461f9
3
+ metadata.gz: fb2e5639dd837ec0e6685bfc6b14de9dd96713ffd837d7a9adb9aa7b6d41c4de
4
+ data.tar.gz: 7f43562f43acd36a2c8755cdab676e8aac9d07c776a147ac31e5cc6142c7e8da
5
5
  SHA512:
6
- metadata.gz: 99be94127829f725b296eed4c2e33b0d9155227568a8e4365ed21ea396f015fb2fa425230546771eed395b3a17ca32ad863a5ecd2353021ac1f64ac74e8cfdff
7
- data.tar.gz: 64889d09e6980042ab94b45d527a62828a768e3a51b74af6e1ec8c8a8e155142728b27bad1231fec29d543fdbaa84b9f9fcc90688b9b68550a05e1b79ee34ba6
6
+ metadata.gz: c64ec42331c055305fc5bfdd52e46e409d49fe576d2c50db4dd438b912256ae912bd2efe18c541bc5056961942ba4be2ebfb1da0c3626b523387aefd232fd6e7
7
+ data.tar.gz: b9862d1f9cab1b6f7e4a072491e003c66dc92c65f9bc929fb986dc030a5d957b34672930f7d0a46742fa19a1e5f93b58f14c0f079222fea89de2c362c5f0817c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [0.3.0] - 2024-04-15
6
+
7
+ ### Added
8
+
9
+ - Added ability to show in the response current probe type
10
+
11
+ ```json
12
+ {
13
+ "data": {
14
+ "id": "a09efd18-e09f-4207-9a43-b4bf89f76b47",
15
+ "type": "application-startup-healthcheck",
16
+ "attributes": {
17
+ "postgres": true,
18
+ "redis": true,
19
+ "rabbit": true
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## [0.2.0] - 2024-03-28
26
+
27
+ ### Added
28
+
29
+ - Added ability to use configuration with default settings without block passing
30
+
31
+ ```ruby
32
+ OnStrum::Healthcheck.configure # It will create configuration instance with default settings
33
+ ```
34
+
35
+ ### Updated
36
+
37
+ - Updated `OnStrum::Healthcheck.configure`, tests
38
+ - Updated gem documentation
39
+
5
40
  ## [0.1.0] - 2024-03-26
6
41
 
7
42
  ### Added
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/b4dc21883d489d67fbef/maintainability)](https://codeclimate.com/github/on-strum/ruby-on-strum-healthcheck/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/b4dc21883d489d67fbef/test_coverage)](https://codeclimate.com/github/on-strum/ruby-on-strum-healthcheck/test_coverage)
5
5
  [![CircleCI](https://circleci.com/gh/on-strum/ruby-on-strum-healthcheck/tree/master.svg?style=svg)](https://circleci.com/gh/on-strum/ruby-on-strum-healthcheck/tree/master)
6
- [![Gem Version](https://badge.fury.io/rb/ruby_healthcheck.svg)](https://badge.fury.io/rb/ruby_healthcheck)
7
- [![Downloads](https://img.shields.io/gem/dt/ruby_healthcheck.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/ruby_healthcheck)
6
+ [![Gem Version](https://badge.fury.io/rb/on_strum-healthcheck.svg)](https://badge.fury.io/rb/on_strum-healthcheck)
7
+ [![Downloads](https://img.shields.io/gem/dt/on_strum-healthcheck.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/on_strum-healthcheck)
8
8
  [![GitHub](https://img.shields.io/github/license/on-strum/ruby-on-strum-healthcheck)](LICENSE.txt)
9
9
  [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
10
10
 
@@ -17,10 +17,12 @@ Simple configurable application healthcheck rack middleware. This middleware all
17
17
  - [Installation](#installation)
18
18
  - [Configuring](#configuring)
19
19
  - [Usage](#usage)
20
- - [Rack](#rack)
21
- - [Roda](#roda)
22
- - [Hanami](#hanami)
23
- - [Rails](#rails)
20
+ - [Integration](#integration)
21
+ - [Rack](#rack)
22
+ - [Roda](#roda)
23
+ - [Hanami](#hanami)
24
+ - [Rails](#rails)
25
+ - [Healthcheck endpoint response](#healthcheck-endpoint-response)
24
26
  - [Contributing](#contributing)
25
27
  - [License](#license)
26
28
  - [Code of Conduct](#code-of-conduct)
@@ -75,7 +77,7 @@ OnStrum::Healthcheck.configure do |config|
75
77
  # and return boolean.
76
78
  # It is equal to empty hash by default.
77
79
  config.services = {
78
- postges: -> { true },
80
+ postgres: -> { true },
79
81
  redis: -> { true },
80
82
  rabbit: -> { false }
81
83
  }
@@ -84,7 +86,7 @@ OnStrum::Healthcheck.configure do |config|
84
86
  # during running startup probe. As array items must be used an
85
87
  # existing keys, defined in config.services.
86
88
  # It is equal to empty array by default.
87
- config.services_startup = %i[postges]
89
+ config.services_startup = %i[postgres]
88
90
 
89
91
  # Optional parameter. The list of services that will be checked
90
92
  # during running liveness probe. As array items must be used an
@@ -96,7 +98,7 @@ OnStrum::Healthcheck.configure do |config|
96
98
  # during running liveness probe. As array items must be used an
97
99
  # existing keys, defined in config.services.
98
100
  # It is equal to empty array by default.
99
- config.services_readiness = %i[postges redis rabbit]
101
+ config.services_readiness = %i[postgres redis rabbit]
100
102
 
101
103
  # Optional parameter. The name of middleware's root
102
104
  # endpoints namespace. Use '/' if you want to use root
@@ -143,28 +145,30 @@ end
143
145
 
144
146
  ## Usage
145
147
 
148
+ ### Integration
149
+
146
150
  Please note, to start using this middleware you should configure `OnStrum::Healthcheck` before and then you should to add `OnStrum::Healthcheck::RackMiddleware` on the top of middlewares list.
147
151
 
148
- ### Rack
152
+ #### Rack
149
153
 
150
154
  ```ruby
151
- require 'rack'
152
155
  require 'on_strum/healthcheck'
153
156
 
157
+ # Configuring OnStrum::Healthcheck with default settings
154
158
  OnStrum::Healthcheck.configure
155
159
 
156
- RackCascade = Rack::Builder.app do
160
+ Rack::Builder.app do
157
161
  use OnStrum::Healthcheck::RackMiddleware
158
162
  run YourApplication
159
163
  end
160
164
  ```
161
165
 
162
- ### Roda
166
+ #### Roda
163
167
 
164
168
  ```ruby
165
- require 'roda'
166
169
  require 'on_strum/healthcheck'
167
170
 
171
+ # Configuring OnStrum::Healthcheck with default settings
168
172
  OnStrum::Healthcheck.configure
169
173
 
170
174
  class YourApplication < Roda
@@ -172,34 +176,60 @@ class YourApplication < Roda
172
176
  end
173
177
  ```
174
178
 
175
- ### Hanami
179
+ #### Hanami
176
180
 
177
181
  ```ruby
178
182
  # config/initializers/on_strum_healthcheck.rb
179
183
 
180
184
  require 'on_strum/healthcheck'
181
185
 
186
+ # Configuring OnStrum::Healthcheck with default settings
182
187
  OnStrum::Healthcheck.configure
188
+ ```
183
189
 
190
+ ```ruby
184
191
  # config/environment.rb
185
192
 
186
193
  Hanami.configure do
187
- middleware.use MyRackMiddleware
194
+ middleware.use OnStrum::Healthcheck::RackMiddleware
188
195
  end
189
196
  ```
190
197
 
191
- ### Rails
198
+ #### Rails
192
199
 
193
200
  ```ruby
194
201
  # config/initializers/on_strum_healthcheck.rb
195
202
 
196
203
  require 'on_strum/healthcheck'
197
204
 
205
+ # Configuring OnStrum::Healthcheck with default settings
198
206
  OnStrum::Healthcheck.configure
207
+ ```
199
208
 
209
+ ```ruby
200
210
  # config/application.rb
201
211
 
202
- config.middleware.use OnStrum::Healthcheck::RackMiddleware
212
+ class Application < Rails::Application
213
+ config.middleware.use OnStrum::Healthcheck::RackMiddleware
214
+ end
215
+ ```
216
+
217
+ ### Healthcheck endpoint response
218
+
219
+ Each healthcheck endpoint returns proper HTTP status and body. Determining the response status is based on the general result of service checks (when all are successful the status is successful, at least one failure - the status is failure). The response body represented as JSON document with a structure like in the example below:
220
+
221
+ ```json
222
+ {
223
+ "data": {
224
+ "id": "a09efd18-e09f-4207-9a43-b4bf89f76b47",
225
+ "type": "application-startup-healthcheck",
226
+ "attributes": {
227
+ "postgres": true,
228
+ "redis": true,
229
+ "rabbit": true
230
+ }
231
+ }
232
+ }
203
233
  ```
204
234
 
205
235
  ## Contributing
@@ -9,7 +9,6 @@ module OnStrum
9
9
 
10
10
  PROBE_ENDPOINTS = %i[endpoint_startup endpoint_liveness endpoint_readiness].freeze
11
11
  CONTENT_TYPE = { 'Content-Type' => 'application/json' }.freeze
12
- JSONAPI_RESPONSE_TYPE = 'application-healthcheck'
13
12
  ROOT_NAMESPACE = '/'
14
13
 
15
14
  def self.call(rack_env)
@@ -75,7 +74,7 @@ module OnStrum
75
74
  {
76
75
  data: {
77
76
  id: ::SecureRandom.uuid,
78
- type: OnStrum::Healthcheck::Resolver::JSONAPI_RESPONSE_TYPE,
77
+ type: "application-#{probe_name}-healthcheck",
79
78
  attributes: probe_result
80
79
  }
81
80
  }.to_json
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OnStrum
4
4
  module Healthcheck
5
- VERSION = '0.1.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -14,6 +14,8 @@ module OnStrum
14
14
  end
15
15
 
16
16
  def configure(&block)
17
+ return configuration {} unless block # rubocop:disable Lint/EmptyBlock
18
+
17
19
  configuration(&block)
18
20
  end
19
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_strum-healthcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack