Skip to content

Commit

Permalink
New content node health check to test network ingress and egress (#4227)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanjunath committed Oct 31, 2022
1 parent fb81802 commit 5d41ca8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion creator-node/src/components/healthCheck/healthCheckController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const {
handleResponse,
successResponse,
handleResponseWithHeartbeat,
errorResponseServerError
errorResponseServerError,
errorResponseBadRequest
} = require('../../apiHelpers')
const {
healthCheck,
Expand Down Expand Up @@ -197,6 +198,24 @@ const healthCheckVerboseController = async (req) => {
})
}

/**
* Controller for `health_check/network` route
*
* Call a discovery node to make sure network egress and ingress is correct
*/
const healthCheckNetworkController = async (req) => {
const { libs } = serviceRegistry
const userId = parseInt(req.query.userId, 10)

if (!userId) return errorResponseBadRequest('Please pass in valid userId')

const user = (await libs.User.getUsers(1, 0, [userId]))[0]

return successResponse({
user
})
}

// Routes

router.get('/health_check', handleResponse(healthCheckController))
Expand All @@ -215,4 +234,9 @@ router.get(
'/health_check/verbose',
handleResponse(healthCheckVerboseController)
)

router.get(
'/health_check/network',
handleResponse(healthCheckNetworkController)
)
module.exports = router

0 comments on commit 5d41ca8

Please sign in to comment.