-
Notifications
You must be signed in to change notification settings - Fork 19
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
(OraklNode) Check network condition and shutdown if necessary #2181
Conversation
WalkthroughWalkthroughThe changes introduce a new ping check mechanism to the application, allowing for the monitoring of endpoint reachability. A cancellable context is implemented to manage the ping operation, which is executed asynchronously after a delay. Additionally, a new Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
go.work.sum
is excluded by!**/*.sum
,!**/*.sum
node/go.mod
is excluded by!**/*.mod
node/go.sum
is excluded by!**/*.sum
,!**/*.sum
Files selected for processing (3)
- node/cmd/node/main.go (2 hunks)
- node/pkg/checker/ping/app.go (1 hunks)
- node/pkg/checker/ping/app_test.go (1 hunks)
Additional comments not posted (11)
node/cmd/node/main.go (3)
12-12
: Import statement forping
package is correctly added.The import statement is necessary for the new functionality and is correctly placed.
23-24
: Context creation and cancellation are correctly implemented.The use of
context.WithCancel
is appropriate for managing the lifecycle of the ping operation. The deferred cancellation ensures resources are properly released.
26-30
: Goroutine for ping operation is correctly implemented.The goroutine allows the ping operation to run asynchronously, which is suitable for non-blocking execution. The delay provides a buffer for application readiness.
However, consider verifying if the 5-second delay is optimal for your use case.
node/pkg/checker/ping/app_test.go (3)
30-53
: Test caseTestApp_Start_SuccessfulPing
is well-structured.The test verifies that a successful ping does not increment the fail count, and the use of a mock pinger allows for controlled testing of the ping logic.
55-75
: Test caseTestApp_Start_FailedPing
is well-structured.The test verifies that a failed ping increments the fail count, and the mock pinger simulates a ping failure effectively.
77-102
: Test caseTestApp_Start_ShutdownOnAllFailures
is comprehensive.The test verifies that the application shuts down when all endpoints fail to ping, and it uses mock pingers to simulate failures effectively.
node/pkg/checker/ping/app.go (5)
12-24
: Constants and global endpoints are well-defined.The constants provide clear configuration defaults, and the global endpoints are well-chosen for network stability checks.
26-40
:PingerInterface
and related types are well-structured.The interface and types provide a clear abstraction for ping operations and results.
42-66
:AppConfig
and option functions are well-implemented.The use of option functions is a common pattern for flexible configuration, and it is well-implemented here.
80-120
:New
function and initialization logic are comprehensive.The initialization logic sets up pingers and result buffers correctly, ensuring the application is ready to run pings.
131-182
:Start
function and ping logic are effectively implemented.The function manages concurrency and context well, and the logic for handling fail counts and shutdowns is crucial for resilience.
However, consider verifying the shutdown logic to ensure it behaves as expected under all failure scenarios.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- node/cmd/node/main.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- node/cmd/node/main.go
while the current implemetation is a good start, I think we can make it more robust considering these points:
i think both of these suggestions require quite a bit of work so not sure if they are realistic to implement within our current deadline |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- node/cmd/node/main.go (2 hunks)
- node/pkg/checker/ping/app.go (1 hunks)
- node/pkg/checker/ping/app_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- node/cmd/node/main.go
- node/pkg/checker/ping/app.go
- node/pkg/checker/ping/app_test.go
|
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.
lgtm!
Description
Ping 3 major DNS which are expected to be stable enough
If all 3 DNS ping fails twice in a row, will shut down the application
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Deployment