-
Notifications
You must be signed in to change notification settings - Fork 25
feat(gateway): add support for new Hive CDN mirror and circuit breaker #1738
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @EmrysMyrddin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the gateway's schema fetching capabilities by introducing support for a new Hive CDN fetcher. This enhancement includes the addition of a secondary CDN mirror for improved resilience and the integration of a circuit breaker mechanism to prevent service degradation during upstream issues. Furthermore, it ensures that all components, particularly the circuit breaker, are properly disposed of when the gateway shuts down, contributing to overall system stability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces support for a secondary CDN mirror and a circuit breaker for Hive, enhancing the reliability of schema fetching. The changes primarily involve refactoring the schema and supergraph fetchers to use the new createCDNArtifactFetcher and to properly handle disposal of resources, which is a great improvement for graceful shutdown. I've identified a minor bug in URL manipulation and a couple of areas where the implementation could be safer and more readable. Overall, this is a solid feature addition.
| ? url | ||
| : joinUrl( | ||
| url.endsWith('/services') | ||
| ? url.substring(0, url.length - 8) |
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.
There seems to be a small off-by-one error here. The length of '/services' is 9, but you are subtracting 8. This will leave a trailing slash in the URL before it's passed to joinUrl. While joinUrl might handle this gracefully, it's more precise to subtract the correct length to avoid potential issues.
| ? url.substring(0, url.length - 8) | |
| ? url.substring(0, url.length - 9) |
| ), | ||
| ); | ||
| const fetcher = createCDNArtifactFetcher({ | ||
| endpoint: endpoints as [string, string], |
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.
The type assertion as [string, string] is not always correct. When a single endpoint string is provided in the configuration, the endpoints array will only contain one element. This cast can hide a type mismatch and lead to potential runtime errors if createCDNArtifactFetcher expects a tuple of two strings. A more accurate type assertion would be safer.
| endpoint: endpoints as [string, string], | |
| endpoint: endpoints as [string, ...string[]], |
| ); | ||
|
|
||
| const fetcher = createCDNArtifactFetcher({ | ||
| endpoint: endpoints as [string, string], |
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.
Similar to the other usage of createCDNArtifactFetcher, the type assertion as [string, string] is not always correct here. If a single endpoint string is provided, the endpoints array will have only one element. This could lead to runtime issues. A more accurate type assertion would be safer.
| endpoint: endpoints as [string, string], | |
| endpoint: endpoints as [string, ...string[]], |
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-tools/batch-delegate |
10.0.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/delegate |
12.0.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/federation |
4.2.4-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-mesh/fusion-runtime |
1.6.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway |
2.1.20-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/nestjs |
2.0.25-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-aws-sigv4 |
2.0.18-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-opentelemetry |
1.2.2-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-mesh/plugin-prometheus |
2.1.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/router-runtime |
1.1.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-runtime |
2.4.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/stitch |
10.1.4-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/stitching-directives |
4.0.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-testing |
3.0.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/wrap |
11.1.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 |
npm ↗︎ unpkg ↗︎ |
| ); | ||
|
|
||
| const fetcher = createCDNArtifactFetcher({ | ||
| endpoint: endpoints as [string, string], |
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 asArray can be used here instead of casting.
| } | ||
| }, | ||
| onDispose() { | ||
| async onDispose() { |
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.
| async onDispose() { | |
| onDispose() { |
| async onDispose() { | ||
| pausePolling(); | ||
| return transportExecutorStack.disposeAsync(); | ||
| await transportExecutorStack.disposeAsync(); |
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.
| await transportExecutorStack.disposeAsync(); | |
| return handleMaybePromise(() => transportExecutorStack.disposeAsync(), () => schemaFetcher.dispose?.()); |
🚀 Snapshot Release (Node Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
🚀 Snapshot Release (Bun Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
|
Since it is not in the todos: Just to make sure: the mirror must also be providable for persisted documents |
a27a06b to
00eb94d
Compare
Description
Adds support for the new Hive CDN fetcher with the addition of a secondary mirror and a circuit breaker.
Details
This PR also ensures the schema fetcher is actually disposed, since the circuit breaker has to be disposed to properly shut down the gateway.
Ref GW-535
Todo