-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: improve retry logic for getting the graph subgraph #615
Merged
+225
−102
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reviewer's Guide by SourceryThis pull request improves the retry logic for fetching graph subgraphs by implementing a dedicated retry mechanism and removing the noCache parameter from several queries. Sequence diagram for improved graph subgraph fetchingsequenceDiagram
participant Client
participant SettlemintClient
participant GraphQLClient
participant Server
Client->>SettlemintClient: graphSubgraphs(uniqueName, noCache)
SettlemintClient->>GraphQLClient: request(getGraphMiddlewareSubgraphs)
GraphQLClient->>Server: POST /graphql
alt Success
Server-->>GraphQLClient: Return data
GraphQLClient-->>SettlemintClient: Return middleware
SettlemintClient-->>Client: Return MiddlewareWithSubgraphs
else Error (5xx, 429, 408)
Server-->>GraphQLClient: Error response
Note over GraphQLClient: Retry with exponential backoff
GraphQLClient->>Server: Retry POST /graphql
end
Class diagram for updated middleware typesclassDiagram
class SettlemintClient {
+middleware: MiddlewareAPI
}
class MiddlewareAPI {
+list(applicationUniqueName: string): Promise~Middleware[]~
+read(middlewareUniqueName: string): Promise~Middleware~
+graphSubgraphs(middlewareUniqueName: string, noCache?: boolean): Promise~MiddlewareWithSubgraphs~
+create(args: CreateMiddlewareArgs): Promise~Middleware~
+restart(middlewareUniqueName: string): Promise~Middleware~
}
class Middleware {
+uniqueName: string
+specVersion: string
}
class MiddlewareWithSubgraphs {
+uniqueName: string
+specVersion: string
+subgraphs: Subgraph[]
}
class Subgraph {
+name: string
+graphqlQueryEndpoint: Endpoint
}
SettlemintClient --> MiddlewareAPI
MiddlewareAPI --> Middleware
MiddlewareAPI --> MiddlewareWithSubgraphs
MiddlewareWithSubgraphs --> Subgraph
Flow diagram for retry logicflowchart TD
A[Start Request] --> B{First Attempt}
B -->|Success| C[Return Response]
B -->|Error| D{Check Error Type}
D -->|5xx/429/408| E[Calculate Retry Delay]
D -->|Other Error| F[Return Error]
E --> G{Max Retries?}
G -->|Yes| H[Retry Request]
G -->|No| I[Throw Error]
H -->|Success| C
H -->|Error| D
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @janb87 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Review instructions: 2 issues found
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
📦 Packages
|
roderik
approved these changes
Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Improve the retry logic when fetching graph subgraphs. Introduce a new
graphSubgraphs
method in the SDK to handle retries and fetch middleware subgraphs. Update the CLI to use the new method.New Features:
graphSubgraphs
method to the SDK to retry fetching middleware subgraphs.Tests:
graphSubgraphs
method.