Skip to content

Commit

Permalink
Updated to match the newest version of the RFC
Browse files Browse the repository at this point in the history
  • Loading branch information
kmakiela committed Jul 2, 2020
1 parent 61bbd1d commit 173503a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ If you specify both **alert** and **data**, target device will receive both noti

### Healthcheck

MongoosePush exposes a `/healthcheck` endpoint, from which you can get information about the current status of all connections in a `JSON` format, grouped by connection pool. Response structure is described in a following [RFC draft](https://tools.ietf.org/id/draft-inadarei-api-health-check-01.html). An example with 2 pools, one being connected to the service and the other one not, would look like this:
MongoosePush exposes a `/healthcheck` endpoint, from which you can get information about the current status of all connections in a `JSON` format, grouped by connection pool. The response structure is described in the following [RFC draft](https://inadarei.github.io/rfc-healthcheck/). An example with 2 pools, one being connected to the service and the other one not, would look like this:

```json
{
Expand Down Expand Up @@ -525,7 +525,7 @@ MongoosePush exposes a `/healthcheck` endpoint, from which you can get informati
"version": "2"
}
```
If all the connections are down the response status is `503` and in all the other cases it's `200`.
If all the connections are down the response status is `503`; in all the other cases, it's `200`.

Please note that it's not recommended to use this frequently as it puts an extra load on the worker processes.

Expand Down
4 changes: 2 additions & 2 deletions lib/mongoose_push_web/controllers/healthcheck_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule MongoosePushWeb.HealthcheckController do
end

# Response formatted to match the draft RFC for healthcheck endpoints, described here:
# https://tools.ietf.org/id/draft-inadarei-api-health-check-01.html
# https://inadarei.github.io/rfc-healthcheck/
defp format_response(connections) do
{_, pool_infos} = Enum.map_reduce(connections, %{}, &format_pool_info/2)

Expand Down Expand Up @@ -83,7 +83,7 @@ defmodule MongoosePushWeb.HealthcheckController do
status: health,
version: List.to_string(Application.spec(:mongoose_push, :vsn)),
description: "Health of MongoosePush connections to FCM and APNS services",
details: pool_infos
checks: pool_infos
}
end

Expand Down
10 changes: 5 additions & 5 deletions test/unit/healthcheck_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule MongoosePushWeb.HealthcheckTest do

response =
pools
|> Map.fetch!("details")
|> Map.fetch!("checks")
|> Map.fetch!("pool:#{pool_name}")
|> List.first()
|> Map.fetch!("output")
Expand Down Expand Up @@ -86,7 +86,7 @@ defmodule MongoosePushWeb.HealthcheckTest do

response =
pools
|> Map.fetch!("details")
|> Map.fetch!("checks")
|> Map.fetch!("pool:#{pool_name}")
|> List.first()
|> Map.fetch!("output")
Expand All @@ -102,7 +102,7 @@ defmodule MongoosePushWeb.HealthcheckTest do

response =
pools
|> Map.fetch!("details")
|> Map.fetch!("checks")
|> Map.fetch!("pool:#{pool_name}")
|> List.first()
|> Map.fetch!("output")
Expand Down Expand Up @@ -163,7 +163,7 @@ defmodule MongoosePushWeb.HealthcheckTest do

response =
pools
|> Map.fetch!("details")
|> Map.fetch!("checks")
|> Map.fetch!("pool:#{pool_name}")
|> List.first()
|> Map.fetch!("output")
Expand All @@ -179,7 +179,7 @@ defmodule MongoosePushWeb.HealthcheckTest do

response =
pools
|> Map.fetch!("details")
|> Map.fetch!("checks")
|> Map.fetch!("pool:#{pool_name}")
|> List.first()
|> Map.fetch!("output")
Expand Down

0 comments on commit 173503a

Please sign in to comment.