-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gateway downstream health checks #3930
Gateway downstream health checks #3930
Conversation
1aeb4c4
to
88d049a
Compare
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.
This looks wonderful! Really a nice addition to the reliability of Gateway and I think addresses the largest concern raised in https://github.com/apollographql/apollo-server/issues/3540.
In that regard, we may also want to provide documentation for how to use it with Apollo Server's onHealthCheck
to meet the requirements of most health-check probes, which might be as simple as:
const gateway = new ApolloGateway({ performServiceHealthChecks: true });
const server = new ApolloServer({
gateway,
onHealthCheck() {
/* Assuming no existing functionality */
return gateway.performServiceHealthChecks();
}
});
... and then a recommendation to leverage https://server:port/.well-known/apollo/server-health
as the endpoint to ping.
Nothing blocking here, and you should feel free to move this forward however you like, but I did leave a few comments within.
5755f83
to
565d96e
Compare
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.
565d96e looks good to me, even if it's a complicated beast.
Let's not do it now, but in the future, we might consider exposing a __testing
property if it makes things particularly more simple. Hiding that from TypeScript might take some slight but worthwhile crafting.
Includes cleanup / DRYing up of the existing GetServiceDefinition query.
49692bb
to
81d9af1
Compare
This commit introduces a new configuration option to the gateway: performServiceHealthChecks. This option adds an additional precautionary step to the gateway load and schema update code paths. A gateway with this setting turned on will send a simple graphql query to all downstream services ({ __typename }) to ensure the service is live and responsive. It performs these queries on initial schema load as well as during a schema update. The interesting failure behaviors are: * On load: throw an error, failure to load. * On schema update: "rollback" (never roll forward). Log the event, but continue serving requests with the old schema. Apollo-Orig-Commit-AS: apollographql/apollo-server@5eef2a6
Purpose
This PR introduces a new configuration option to the gateway:
performServiceHealthChecks
. This option adds an additional precautionary step to the gateway load and schema update code paths.A gateway with this setting turned on will send a simple graphql query to all downstream services (
{ __typename }
) to ensure the service is life and responsive. It performs these queries on initial schema load as well as during a schema update. The interesting failure behaviors are:TODO: