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

da: add client context #28

Merged
merged 1 commit into from
Jan 12, 2024
Merged

da: add client context #28

merged 1 commit into from
Jan 12, 2024

Conversation

tuxcanfly
Copy link
Contributor

@tuxcanfly tuxcanfly commented Dec 21, 2023

Overview

This PR adds a context to all DA interface methods so that clients can gracefully handle timeouts and/or errors.

Note: This is a breaking change for clients which depend on DA interface.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features

    • Search bar introduced to enhance user navigation and content discovery.
  • Refactor

    • Improved context handling across various operations for better request management.
  • Tests

    • Updated tests to incorporate context-aware calls with timeouts, ensuring operations are cancellable and adhere to expected time constraints.

Copy link

coderabbitai bot commented Dec 21, 2023

Warning

Rate Limit Exceeded

@tuxcanfly has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 22 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 755acd2 and bff650e.

Walkthrough

The recent updates involve integrating context.Context into various method signatures, enhancing the management of timeouts, cancellations, and other request-related metadata. This change affects RPC calls and ensures operations are context-aware, allowing for better control over execution flow and resource management.

Changes

File Group Change Summary
da.go, proxy/client.go, test/dummy.go Updated the DA interface and Client type to include a context.Context parameter in methods like MaxBlobSize, Get, GetIDs, Commit, Submit, and Validate.
proxy/server.go, test/test_suite.go Modified method calls to include the ctx parameter for context handling in method invocations and added context handling to various function calls in tests.

🐇✨
To the code, a context we add,
For requests that linger a tad.
With a hop and a skip, deadlines we set,
No more waiting, no reason to fret. 🕒🚫

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

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. 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 and a 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. 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)

  • @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

codecov bot commented Dec 21, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (755acd2) 79.31% compared to head (bff650e) 79.31%.

Files Patch % Lines
proxy/client.go 83.33% 2 Missing ⚠️
proxy/server.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #28   +/-   ##
=======================================
  Coverage   79.31%   79.31%           
=======================================
  Files           3        3           
  Lines         174      174           
=======================================
  Hits          138      138           
  Misses         28       28           
  Partials        8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 ad9f599 and c8cfc07.
Files selected for processing (5)
  • da.go (1 hunks)
  • proxy/client.go (5 hunks)
  • proxy/server.go (4 hunks)
  • test/dummy.go (6 hunks)
  • test/test_suite.go (6 hunks)
Additional comments: 6
da.go (6)
  • 8-8: The addition of context.Context as the first parameter to MaxBlobSize aligns with Go's standard practice for handling request lifecycles and allows for better control over RPC operations.

  • 14-14: The addition of context.Context as the first parameter to Get is a good practice for managing timeouts and cancellations of requests.

  • 17-17: Incorporating context.Context into GetIDs enhances the method's ability to handle request-scoped values and control flow.

  • 20-20: Adding context.Context to Commit is essential for context-aware operations, especially for long-running processes that may require cancellation.

  • 26-26: The Submit method now correctly takes a context.Context parameter, allowing clients to manage the operation with respect to timeouts and cancellations.

  • 29-29: The Validate method's update to include context.Context is a positive change, ensuring that validation operations are context-aware.

Manav-Aggarwal
Manav-Aggarwal previously approved these changes Dec 22, 2023
@gupadhyaya gupadhyaya self-requested a review January 4, 2024 04:36
gupadhyaya
gupadhyaya previously approved these changes Jan 4, 2024
@tuxcanfly tuxcanfly dismissed stale reviews from gupadhyaya and Manav-Aggarwal via cb6c05d January 9, 2024 15:27
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 704b67e and cb6c05d.
Files selected for processing (5)
  • da.go (2 hunks)
  • proxy/client.go (5 hunks)
  • proxy/server.go (4 hunks)
  • test/dummy.go (6 hunks)
  • test/test_suite.go (6 hunks)
Additional comments: 28
da.go (6)
  • 15-15: Adding context.Context as the first parameter to MaxBlobSize is in line with Go's convention for context usage in interfaces. This change will allow for better request management and cancellation.

  • 21-21: The Get method now correctly takes a context.Context as the first parameter, enabling improved error handling and request cancellation.

  • 24-24: The GetIDs method has been updated to accept a context.Context parameter, which is a standard practice for handling request lifecycles in Go.

  • 27-27: The Commit method's signature now includes context.Context, aligning with Go's context pattern for managing timeouts and cancellations.

  • 34-34: The Submit method correctly includes a context.Context parameter, allowing clients to manage the request lifecycle effectively.

  • 37-37: The Validate method has been updated to take a context.Context as the first parameter, which is consistent with Go's context handling pattern.

proxy/server.go (6)
  • 28-28: The MaxBlobSize method in the proxy server now correctly passes the context.Context to the underlying DA method.

  • 34-34: The Get method implementation in the proxy server has been updated to include the context.Context when calling the underlying DA method.

  • 39-39: The GetIDs method in the proxy server now properly includes the context.Context in its call to the underlying DA method.

  • 49-49: The Commit method in the proxy server has been correctly updated to pass the context.Context to the DA's Commit method.

  • 61-61: The Submit method in the proxy server now passes the context.Context to the underlying DA method, aligning with the context handling pattern in Go.

  • 83-83: The Validate method in the proxy server has been updated to include the context.Context when calling the DA's Validate method.

proxy/client.go (6)
  • 41-41: The MaxBlobSize method of the Client type now correctly accepts a context.Context parameter.

  • 51-51: The Get method of the Client type has been updated to include a context.Context parameter, which is a standard practice in Go for handling request lifecycles.

  • 67-67: The GetIDs method of the Client type now takes a context.Context parameter, allowing for better request management.

  • 78-78: The Commit method signature in the Client type has been correctly updated to include a context.Context parameter.

  • 92-92: The Submit method of the Client type now includes a context.Context parameter, aligning with Go's context handling pattern.

  • 114-114: The Validate method of the Client type has been updated to accept a context.Context parameter, which is consistent with Go's context handling pattern.

test/dummy.go (6)
  • 53-53: The MaxBlobSize method of the DummyDA struct now correctly includes a context.Context parameter.

  • 58-58: The Get method of the DummyDA struct has been updated to include a context.Context parameter, which is a standard practice in Go for handling request lifecycles.

  • 82-82: The GetIDs method of the DummyDA struct now takes a context.Context parameter, allowing for better request management.

  • 94-94: The Commit method signature in the DummyDA struct has been correctly updated to include a context.Context parameter.

  • 103-103: The Submit method of the DummyDA struct now includes a context.Context parameter, aligning with Go's context handling pattern.

  • 120-120: The Validate method of the DummyDA struct has been updated to accept a context.Context parameter, which is consistent with Go's context handling pattern.

test/test_suite.go (4)
  • 44-44: The BasicDATest function now correctly creates a context using context.TODO() for use in DA method calls.

  • 106-108: The CheckErrors function properly creates a context with a timeout using context.WithTimeout and uses it in the Get call.

  • 117-117: The GetIDsTest function has been updated to create a context using context.TODO() for use in DA method calls.

  • 159-161: The ConcurrentReadWriteTest function correctly creates a context with a timeout using context.WithTimeout for use in DA method calls.

@Manav-Aggarwal Manav-Aggarwal merged commit 82f5296 into main Jan 12, 2024
12 checks passed
@Manav-Aggarwal Manav-Aggarwal deleted the tux/client-context branch January 12, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants