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

Break on empty events when loading from remote #2376

Merged
merged 2 commits into from
Sep 1, 2024
Merged

Conversation

kariy
Copy link
Member

@kariy kariy commented Sep 1, 2024

currently we only stop querying for events when the provider no longer returns a continuation token. this pr adds an extra safety net to stop immediately when there are no more events being returned.

though the spec mentions explicitly that the token Should not appear if there are no more pages. but it doesn't mention exactly how the token should behave with pending block as the list of events in the pending block could still grow.

there could be a case where someone calls getEvents with the the to block sets to=pending. if they already reach the end of the pending block during the first call, yet the block could still emit new events. but if the returned continuation token is nil, then if the user wants to continue from the last events in the first call, they couldn't and had to start from the beginning again.

ref: #2375

Summary by CodeRabbit

  • New Features
    • Improved event retrieval efficiency by terminating early when no events are returned, enhancing performance and reducing unnecessary processing.

Copy link

coderabbitai bot commented Sep 1, 2024

Walkthrough

Ohayo, sensei! The changes involve a modification to the get_events function in the manifest module. The function now includes a condition to terminate the event retrieval loop if the returned events array is empty, enhancing the control flow and efficiency of event processing.

Changes

File Path Change Summary
crates/dojo-world/src/manifest/mod.rs Updated get_events function to break loop on empty events array.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Provider
    Client->>Provider: Request events with continuation token
    Provider-->>Client: Return events and continuation token
    alt Events returned
        Client->>Client: Append events to collection
        Client->>Provider: Request next events with token
    else No events returned
        Client->>Client: Break loop
    end
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 24bfd4b and 70ecd82.

Files selected for processing (1)
  • crates/dojo-world/src/manifest/mod.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/dojo-world/src/manifest/mod.rs

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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 1, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.85%. Comparing base (f62acf2) to head (70ecd82).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/dojo-world/src/manifest/mod.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2376      +/-   ##
==========================================
+ Coverage   67.72%   67.85%   +0.12%     
==========================================
  Files         359      359              
  Lines       47034    46959      -75     
==========================================
+ Hits        31854    31862       +8     
+ Misses      15180    15097      -83     

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

@kariy kariy merged commit 1d95782 into main Sep 1, 2024
15 checks passed
@kariy kariy deleted the loadfromremote/main-loop branch September 1, 2024 22:33
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.

1 participant