-
Notifications
You must be signed in to change notification settings - Fork 29
Write HealthCheck route #154
base: master
Are you sure you want to change the base?
Conversation
Generated by 🚫 dangerJS |
ops/health-check-route.s.md
Outdated
|
||
# Why | ||
|
||
In order to monitor correctly their environments, some Cloud services require a HealthCheck route which returns a status depending on how the API is running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could apply to any backend service
ops/health-check-route.s.md
Outdated
|
||
## Checks | ||
|
||
- [ ] Do a call to every DB used by the API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a call / database
ops/health-check-route.s.md
Outdated
|
||
- [ ] Do a call to every DB used by the API | ||
- [ ] Send a 2xx status code status in case of API running correctly and 5xx status code if not | ||
- [ ] Do the less data usage DB calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make -> why?
ops/health-check-route.s.md
Outdated
return res.status(200).send({ status: 200, message: "OK" }); | ||
} | ||
|
||
nextFetchingDate = Date.now() + TIME_CHECKING_INTERVAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe put nextFetchingDate
before the catch
ops/health-check-route.s.md
Outdated
- [ ] Do a call to every DB used by the API | ||
- [ ] Send a 2xx status code status in case of API running correctly and 5xx status code if not | ||
- [ ] Do the less data usage DB calls | ||
- [ ] Include a timestamp in order not to reduce the number of successive calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove this check?
ops/health-check-route.s.md
Outdated
```javascript | ||
app.get("/health", async (req, res) => { | ||
try { | ||
await findAllDataCollectors(); // DataCollectors ~ 100 entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can be more generic, like RDS.getAll
ops/health-check-route.s.md
Outdated
} | ||
|
||
nextFetchingDate = Date.now() + TIME_CHECKING_INTERVAL; | ||
await Promise.all([AppsDynamoRepo.getDynamoHealth(), getHealth()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mayeb more generic in your examples -> what is getHealth
467572a
to
cd24cf7
Compare
ops/health-check-route.s.md
Outdated
## Checks | ||
|
||
- [ ] Make a call to every database used by the API | ||
- [ ] Send a 2xx status code status in case of API running correctly and 5xx status code if not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send a 2xx status code status if the API is running correctly, 5xx status code if not
ops/health-check-route.s.md
Outdated
|
||
- [ ] Make a call to every database used by the API | ||
- [ ] Send a 2xx status code status in case of API running correctly and 5xx status code if not | ||
- [ ] Make the less data usage database calls: the health check route is likely to be called very often in short period of time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make database calls retrieving as little data as possible
ops/health-check-route.s.md
Outdated
|
||
## Examples | ||
|
||
In the examples below the API is concentrating calls to one database RDS and one DynamoDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concentrating? Did you mean making?
ops/health-check-route.s.md
Outdated
|
||
- There is a call to one of the database but not the other | ||
- The call is using too much data | ||
- There is a 503 if the DB is down |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain why 503
ops/health-check-route.s.md
Outdated
await knex.raw("select 1+1 as result"); | ||
}; | ||
|
||
DynamoDB.getDynamoHealth = (): Promise<Array<Object>> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove typing as it is not used anywhere else
e5e4e70
to
95ffe1f
Compare
Can you liaise with Louis to merge your standard into his? |
No description provided.