Skip to content

Commit

Permalink
Merge pull request #54 from envato/release-0.3.0
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
liamdawson authored Sep 8, 2023
2 parents 3808274 + c2808f6 commit 68f1e19
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 13 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ inherit_gem:

AllCops:
SuggestExtensions: false
NewCops: disable
Exclude:
- 'vendor/**/*'

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.2.2
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [0.3.0] - 2023-09-08

### Added

- (#53) Add a configuration option for the unhealthy status code - thanks @floere!

### Removed

- **Breaking:** Dropped support for Ruby versions < 2.7.0
Expand Down Expand Up @@ -79,7 +85,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- `git_revision` check to return the current git revision
- `migration_version` check to return the current ActiveRecord migration version

[Unreleased]: https://github.com/envato/rack-ecg/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/envato/rack-ecg/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/envato/rack-ecg/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/envato/rack-ecg/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/envato/rack-ecg/compare/v0.0.5...v0.1.0
[0.0.5]: https://github.com/envato/rack-ecg/compare/v0.0.4...v0.0.5
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APIs and features are almost certain to be in flux.
Add this to your application's `Gemfile`:

```ruby
gem 'rack-ecg', '~> 0.2.0`
gem 'rack-ecg', '~> 0.3.0`
```
Then run `bundle install`.
Expand Down Expand Up @@ -241,7 +241,14 @@ use Rack::ECG, hook: Proc.new { |success, _checks| puts "Is healthy? #{success}"
- `success`: whether the response will indicate success
- `checks`: an array of the check names and values

More examples are provided in [/examples](https://github.com/envato/rack-ecg/tree/main/examples)
### `failure_status`

By default, check failures result in a HTTP status code `500` (Internal Server
Error). You can change this code by setting the `failure_status` option. e.g.

```ruby
use Rack::ECG, checks: [:error], failure_status: 503
```

## Requirements

Expand All @@ -252,6 +259,10 @@ More examples are provided in [/examples](https://github.com/envato/rack-ecg/tre
- To use optional `migration_version` check, you must be using ActiveRecord and
migrations stored in `schema_versions` table

## Examples

Some configuration examples are provided in [/examples](https://github.com/envato/rack-ecg/tree/main/examples).

## Contact

- [github project](https://github.com/envato/rack-ecg)
Expand Down
11 changes: 11 additions & 0 deletions examples/custom_failure_status.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "rack/ecg"

use(
Rack::ECG,
checks: [:error],
failure_status: 503,
)

run(->(_env) { [200, {}, ["Hello, World"]] })
2 changes: 1 addition & 1 deletion examples/git_revision_check_replacement.ru
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def git_revision
{ name: :git_revision, status: status, value: value }
end

use(Rack::ECG, { checks: [[:static, git_revision]] })
use(Rack::ECG, checks: [[:static, git_revision]])

run(->(_env) { [200, {}, ["Hello, World"]] })
5 changes: 3 additions & 2 deletions lib/rack/ecg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ECG
# @param at [String, nil] Path which this ECG instance handles.
# @param hook [#call, nil] Callable which receives the success status and
# check results
# @param failure_status [Integer] Status code to return on check failure
def initialize(app = nil, checks: DEFAULT_CHECKS, at: DEFAULT_MOUNT_AT, hook: nil,
failure_status: DEFAULT_FAILURE_STATUS)
@app = app
Expand Down Expand Up @@ -51,8 +52,8 @@ def call(env)
@result_hook&.call(success, check_results)

response_headers = {
"X-Rack-ECG-Version" => Rack::ECG::VERSION,
"Content-Type" => "application/json",
"x-rack-ecg-version" => Rack::ECG::VERSION,
"content-type" => "application/json",
}

response_body = JSON.pretty_generate(check_results)
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/ecg/check/error.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative "./static"
require_relative "static"

module Rack
class ECG
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/ecg/check/http.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative "./static"
require_relative "static"

module Rack
class ECG
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/ecg/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module Rack
class ECG
# Library version.
VERSION = "0.2.0"
VERSION = "0.3.0"
end
end
7 changes: 4 additions & 3 deletions rack-ecg.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency("rack")

spec.add_development_dependency("pry", "~> 0.14.1")
spec.add_development_dependency("pry", "~> 0.14.2")
spec.add_development_dependency("rack-test", "~> 2.1.0")
spec.add_development_dependency("rackup", "~> 2.1.0")
spec.add_development_dependency("rake", "~> 13.0")
spec.add_development_dependency("redcarpet", "~> 3.6.0")
spec.add_development_dependency("rspec", "~> 3.12.0")
spec.add_development_dependency("rubocop-shopify", "~> 2.10")
spec.add_development_dependency("yard", "~> 0.9.24")
spec.add_development_dependency("rubocop-shopify", "~> 2.14")
spec.add_development_dependency("yard", "~> 0.9.34")
end

0 comments on commit 68f1e19

Please sign in to comment.