Skip to content

Commit

Permalink
Merge pull request #30 from on-strum/develop
Browse files Browse the repository at this point in the history
OnStrum::Healthcheck v0.3.0
  • Loading branch information
bestwebua authored Apr 15, 2024
2 parents 7591ec5 + 95ea0ac commit c6bebc4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

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).

## [0.3.0] - 2024-04-15

### Added

- Added ability to show in the response current probe type

```json
{
"data": {
"id": "a09efd18-e09f-4207-9a43-b4bf89f76b47",
"type": "application-startup-healthcheck",
"attributes": {
"postgres": true,
"redis": true,
"rabbit": true
}
}
}
```

## [0.2.0] - 2024-03-28

### Added
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ OnStrum::Healthcheck.configure do |config|
# and return boolean.
# It is equal to empty hash by default.
config.services = {
postges: -> { true },
postgres: -> { true },
redis: -> { true },
rabbit: -> { false }
}
Expand All @@ -86,7 +86,7 @@ OnStrum::Healthcheck.configure do |config|
# during running startup probe. As array items must be used an
# existing keys, defined in config.services.
# It is equal to empty array by default.
config.services_startup = %i[postges]
config.services_startup = %i[postgres]

# Optional parameter. The list of services that will be checked
# during running liveness probe. As array items must be used an
Expand All @@ -98,7 +98,7 @@ OnStrum::Healthcheck.configure do |config|
# during running liveness probe. As array items must be used an
# existing keys, defined in config.services.
# It is equal to empty array by default.
config.services_readiness = %i[postges redis rabbit]
config.services_readiness = %i[postgres redis rabbit]

# Optional parameter. The name of middleware's root
# endpoints namespace. Use '/' if you want to use root
Expand Down Expand Up @@ -191,7 +191,7 @@ OnStrum::Healthcheck.configure
# config/environment.rb

Hanami.configure do
middleware.use MyRackMiddleware
middleware.use OnStrum::Healthcheck::RackMiddleware
end
```

Expand Down Expand Up @@ -222,11 +222,11 @@ Each healthcheck endpoint returns proper HTTP status and body. Determining the r
{
"data": {
"id": "a09efd18-e09f-4207-9a43-b4bf89f76b47",
"type": "application-healthcheck",
"type": "application-startup-healthcheck",
"attributes": {
"postges": true,
"postgres": true,
"redis": true,
"rebbit": true
"rabbit": true
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/on_strum/healthcheck/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Resolver

PROBE_ENDPOINTS = %i[endpoint_startup endpoint_liveness endpoint_readiness].freeze
CONTENT_TYPE = { 'Content-Type' => 'application/json' }.freeze
JSONAPI_RESPONSE_TYPE = 'application-healthcheck'
ROOT_NAMESPACE = '/'

def self.call(rack_env)
Expand Down Expand Up @@ -75,7 +74,7 @@ def response_jsonapi
{
data: {
id: ::SecureRandom.uuid,
type: OnStrum::Healthcheck::Resolver::JSONAPI_RESPONSE_TYPE,
type: "application-#{probe_name}-healthcheck",
attributes: probe_result
}
}.to_json
Expand Down
2 changes: 1 addition & 1 deletion lib/on_strum/healthcheck/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module OnStrum
module Healthcheck
VERSION = '0.2.0'
VERSION = '0.3.0'
end
end
4 changes: 2 additions & 2 deletions spec/on_strum/healthcheck/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
describe 'defined constants' do
it { expect(described_class).to be_const_defined(:PROBE_ENDPOINTS) }
it { expect(described_class).to be_const_defined(:CONTENT_TYPE) }
it { expect(described_class).to be_const_defined(:JSONAPI_RESPONSE_TYPE) }
it { expect(described_class).to be_const_defined(:ROOT_NAMESPACE) }
end

Expand Down Expand Up @@ -41,11 +40,12 @@
end

it 'returns rack middleware response' do
response_status, _content_type, _response = resolver
response_status, _content_type, response_body = resolver

expect(response_status).to eq(
current_configuration.public_send(:"endpoint_#{probe_name}_status_success")
)
expect(response_body.first).to include("application-#{probe_name}-healthcheck")
end
end

Expand Down

0 comments on commit c6bebc4

Please sign in to comment.