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

Fixes #1938: Updated healthCheck for Posts service #2165

Merged
merged 8 commits into from
Apr 19, 2021
Merged

Fixes #1938: Updated healthCheck for Posts service #2165

merged 8 commits into from
Apr 19, 2021

Conversation

HyperTHD
Copy link
Contributor

Issue This PR Addresses

This PR closes #1938

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

With Redis added to Satellite, I'm able to update the posts service's health check to check if redis is functioning by using the ping function from Redis. This PR also updates the routes for the posts service to use the createError function and call that function using the next function as part of the catch.

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

One small thing and this is ready.

Reading your code, I also realize that we need to add a way to tell the Redis connection to close just as we're shutting down. Right now we don't expose a hook for this from Satellite, but we can add one.

src/api/posts/src/index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

I think to get the unit tests to pass, you're going to have to move your redis instance out of index.js and into its own file? Not sure, but redis being undefined in the tests is odd.

src/api/posts/src/index.js Outdated Show resolved Hide resolved
chrispinkney
chrispinkney previously approved these changes Apr 16, 2021
Copy link
Contributor

@chrispinkney chrispinkney left a comment

Choose a reason for hiding this comment

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

LGTM besides the nit pointed out by Dave.

@HyperTHD
Copy link
Contributor Author

@humphd. I might need to wait for the shutdown option to be merged into Satellite. Even in it's own file, redis seems to be undefined which is super weird

@humphd
Copy link
Contributor

humphd commented Apr 18, 2021

I had an epiphany while on a walk today: did we add Redis since the last npm update for Satellite? We probably need to ship an update that includes it. I just triggered 1.12.0, which should hit npm within the next 30 mins. Let's try that and see what happens here.

humphd
humphd previously approved these changes Apr 18, 2021
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

This looks good. The only minor nit I have is that you're only exporting a single thing from redis.js, so I would module.exports = redis instead, so you can const redis = require('./redis'); and not bother with destructuring. But it's minor.

I agree, we should do a follow-up to add the shutdown logic for redis too, once that lands.

src/api/posts/src/index.js Outdated Show resolved Hide resolved
src/api/posts/src/storage.js Outdated Show resolved Hide resolved
humphd
humphd previously approved these changes Apr 18, 2021
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Perfect.

@humphd humphd requested a review from chrispinkney April 18, 2021 21:40
chrispinkney
chrispinkney previously approved these changes Apr 19, 2021
Copy link
Contributor

@chrispinkney chrispinkney left a comment

Choose a reason for hiding this comment

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

LGTM

@HyperTHD
Copy link
Contributor Author

Rebased, @humphd @chrispinkney, let's get this merged in

@HyperTHD HyperTHD requested review from humphd and chrispinkney April 19, 2021 15:45
humphd
humphd previously approved these changes Apr 19, 2021
humphd
humphd previously approved these changes Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update posts healthcheck with Redis check
3 participants