Skip to content
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

[Tenscan] Endpoint for health check #1718

Conversation

Jennievon
Copy link
Contributor

Why this change is needed

Please provide a description and a link to the underlying ticket

https://github.com/ten-protocol/ten-internal/issues/2624

What changes were made as part of this PR

Please provide a high level list of the changes made

Add an endpoint for health check on Tenscan backend

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@Jennievon Jennievon requested a review from otherview December 22, 2023 12:14
Copy link

coderabbitai bot commented Dec 22, 2023

Walkthrough

The codebase has undergone a refactor where the Health method has been renamed to HealthStatusOfNode in the ObsClient interface. This change necessitates updates across several files where the method is called. Additionally, the backend for obscuroscan_v2 has been enhanced with a new GetHealthStatus function, and the web server routes have been updated to include a new endpoint for health status checks, which uses the updated ObsClient method to return the node's health as JSON.

Changes

File Path Change Summary
go/obsclient/obsclient.go Renamed Health to HealthStatusOfNode in ObsClient.
.../networktest/env/dev_network.go
.../networktest/util.go
.../simulation/network/socket.go
.../simulation/simulation.go
testnet/launcher/docker.go
Updated method call from Health to HealthStatusOfNode.
tools/obscuroscan_v2/backend/.../backend.go Added GetHealthStatus function in Backend.
tools/obscuroscan_v2/backend/webserver/.../items.go Added new route for health status and getHealthStatus method in WebServer.

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?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c990832 and 9896ed7.
Files selected for processing (8)
  • go/obsclient/obsclient.go (1 hunks)
  • integration/networktest/env/dev_network.go (1 hunks)
  • integration/networktest/util.go (1 hunks)
  • integration/simulation/network/socket.go (1 hunks)
  • integration/simulation/simulation.go (1 hunks)
  • testnet/launcher/docker.go (1 hunks)
  • tools/obscuroscan_v2/backend/obscuroscan_backend.go (1 hunks)
  • tools/obscuroscan_v2/backend/webserver/webserver_routes_items.go (1 hunks)
Additional comments: 8
integration/networktest/util.go (1)
  • 27-30: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the NodeHealthCheck function.
integration/networktest/env/dev_network.go (1)
  • 53-56: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the awaitHealthStatus function.
tools/obscuroscan_v2/backend/obscuroscan_backend.go (1)
  • 33-35: The addition of GetHealthStatus to the Backend type is consistent with the changes made to the ObsClient type. Ensure that the new method is used appropriately within the backend logic.
tools/obscuroscan_v2/backend/webserver/webserver_routes_items.go (1)
  • 20-27: The new route /info/health/ and its handler getHealthStatus have been added correctly. Verify that the error handling in the getHealthStatus method is appropriate and that the health status is being returned as expected.
go/obsclient/obsclient.go (1)
  • 89-93: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the ObsClient type.
integration/simulation/network/socket.go (1)
  • 176-179: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the createConnections method.
testnet/launcher/docker.go (1)
  • 226-229: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the waitForHealthyNode function.
integration/simulation/simulation.go (1)
  • 291-293: The method HealthStatusOfNode has been correctly updated from Health. Ensure that the new method's behavior is consistent with the expected functionality of the checkHealthStatus method.

@Jennievon Jennievon requested a review from zkokelj December 22, 2023 12:17
@Jennievon Jennievon self-assigned this Dec 22, 2023
@Jennievon Jennievon changed the title Jennifer/2624 add a health indicator for testnet on tenscan and the gateway [Tenscan] Endpoint for health check Dec 22, 2023
…nnifer/2624-add-a-health-indicator-for-testnet-on-tenscan-and-the-gateway
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9896ed7 and 2394bbf.
Files selected for processing (5)
  • integration/simulation/network/socket.go (1 hunks)
  • integration/simulation/simulation.go (1 hunks)
  • testnet/launcher/docker.go (1 hunks)
  • tools/tenscan/backend/obscuroscan_backend.go (1 hunks)
  • tools/tenscan/backend/webserver/webserver_routes_items.go (1 hunks)
Additional comments: 4
tools/tenscan/backend/obscuroscan_backend.go (1)
  • 33-35: The GetHealthStatus method correctly delegates to obsClient.HealthStatusOfNode and returns its result, allowing the caller to handle any errors.
tools/tenscan/backend/webserver/webserver_routes_items.go (1)
  • 20-27: The new health check route and its handler getHealthStatus are correctly implemented, with proper error handling and JSON response formatting.
integration/simulation/network/socket.go (1)
  • 181-187: The modification to use HealthStatusOfNode in the createConnections method is correctly implemented, with a loop that waits for node health or times out appropriately.
testnet/launcher/docker.go (1)
  • 225-231: The update to waitForHealthyNode to use HealthStatusOfNode is correctly implemented, with proper error handling and retry logic.

integration/simulation/simulation.go Outdated Show resolved Hide resolved
go/obsclient/obsclient.go Outdated Show resolved Hide resolved
tools/tenscan/backend/obscuroscan_backend.go Outdated Show resolved Hide resolved
tools/tenscan/backend/webserver/webserver_routes_items.go Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2394bbf and ba87900.
Files selected for processing (2)
  • tools/tenscan/backend/obscuroscan_backend.go (1 hunks)
  • tools/tenscan/backend/webserver/webserver_routes_items.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tools/tenscan/backend/obscuroscan_backend.go
  • tools/tenscan/backend/webserver/webserver_routes_items.go

…nnifer/2624-add-a-health-indicator-for-testnet-on-tenscan-and-the-gateway
@Jennievon Jennievon merged commit f77ac97 into main Jan 8, 2024
1 of 2 checks passed
@Jennievon Jennievon deleted the jennifer/2624-add-a-health-indicator-for-testnet-on-tenscan-and-the-gateway branch January 8, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants