Skip to content

Commit

Permalink
code review fixes - minor docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
eranharel committed Nov 20, 2019
1 parent 6a88b69 commit 19e9d07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ The `short` response type is suitable for the consul health checks / LB heath ch
The response code is `200` when the tests pass, and `503` when they fail.

### CheckListener
It is sometimes desired to keep track on checks execution and apply custom logic.
It is sometimes desired to keep track of checks execution and apply custom logic.
For example, you may want to add logging, or external metrics to your checks,
or add some trigger some recovery logic when a check fails after 3 consecutive times.

The `health.CheckListener` interface allows you to do hook this custom logic.
The `health.CheckListener` interface allows you to hook this custom logic.

For example, lets add a logging listener to our health repository:
```go
Expand All @@ -321,7 +321,7 @@ func (l checkEventsLogger) OnCheckCompleted(name string, res health.Result) {
}
```

Please note that your `CheckListener` implementation must not block! the
Please note that your `CheckListener` implementation must not block!

## Metrics
The library exposes the following OpenCensus view for your convenience:
Expand Down
5 changes: 4 additions & 1 deletion health.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ type Health interface {
}

// CheckListener can be used to gain check stats or log check transitions.
// Implementations of this interface **must not block**
// Implementations of this interface **must not block!**
// If an implementation blocks, it may result in delayed execution of other health checks down the line.
// It's OK to log in the implementation and it's OK to add metrics, but it's not OK to run anything that
// takes long time to complete such as network IO etc.
type CheckListener interface {
// OnCheckStarted is called when a check with the specified name has started
OnCheckStarted(name string)
Expand Down

0 comments on commit 19e9d07

Please sign in to comment.