Skip to content

Commit

Permalink
Simplify documentation about the check interface
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Jul 12, 2018
1 parent f1a2519 commit 0658c97
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions docs/healthchecks.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Health Checks

Set up a route in your rack-compatible Ruby application, and pick the built-in
or custom checks you wish to perform.
## Check interface

Custom checks must be a class which implements
[this interface](../spec/lib/govuk_healthcheck/shared_interface.rb):
A check is expected to be a class with the following methods:

```ruby
class CustomCheck
def name
:custom_check
:the_name_of_the_check
end

def status
ThingChecker.everything_okay? ? OK : CRITICAL
if critical_condition?
:critical
elsif warning_condition?
:warning
else
:ok
end
end

# Optional
Expand All @@ -30,6 +34,15 @@ class CustomCheck
end
```

It is expected that these methods may cache their results for performance
reasons, if a user wants to ensure they have the latest value they should
create a new instance of the check first.

# Including checks in your app

Set up a route in your rack-compatible Ruby application, and pick the built-in
or custom checks you wish to perform.

For Rails apps:

```ruby
Expand All @@ -40,14 +53,6 @@ get "/healthcheck", to: GovukHealthcheck.rack_response(
)
```

This will check:
- Redis connectivity (via Sidekiq)
- Database connectivity (via ActiveRecord)
- Your custom healthcheck

Each check class gets instanced each time the health check end point is called.
This allows you to cache any complex queries speeding up performance.

## Built-in Checks

### `SidekiqRedis`
Expand Down

0 comments on commit 0658c97

Please sign in to comment.