Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MET-425 Create a common healthcheck plugin for public and private endpoints #220

Merged
merged 4 commits into from
Nov 29, 2024

Conversation

andrewi-wd
Copy link
Contributor

@andrewi-wd andrewi-wd commented Nov 25, 2024

Changes

This PR adds a new commonHealthcheckPlugin, which is registering two routes:

  • A public one GET /
  • A private one GET /health

Public route contain only resulting heartbeat from all provided healthchecks in a response. Extra info is also omitted.

Private route contain exactly the same response as publicHealthcheckPlugin has.

Checklist

  • Apply one of following labels; major, minor, patch or skip-release
  • I've updated the documentation, or no changes were necessary
  • I've updated the tests, or no changes were necessary


if (opts.healthChecks.length) {
const results = await Promise.all(
opts.healthChecks.map(async (healthcheck) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mixing async/await and callbacks is often not the best idea, I would recommend to keep the original style of

          opts.healthChecks.map((healthcheck) => {
            return healthcheck.checker(app).then((result) => {
              if (result.error) {
                app.log.error(result.error, `${healthcheck.name} healthcheck has failed`)
              }
              return {
                name: healthcheck.name,
                result,
                isMandatory: healthcheck.isMandatory,
              }
            })
          }),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 4306cba

@kibertoad
Copy link
Collaborator

@andrewi-wd should this be a breaking change (semver major)?

@andrewi-wd
Copy link
Contributor Author

@andrewi-wd should this be a breaking change (semver major)?

@kibertoad I don't think so. I haven't modified existing healthcheck that is used, so there must be no problem with updates.

@andrewi-wd andrewi-wd merged commit 7a24bc9 into main Nov 29, 2024
4 checks passed
@andrewi-wd andrewi-wd deleted the feat/MET-425_Common_healthcheck_plugin branch November 29, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants