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

fix: emit trace for unprocessed event only once #2352

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

lambda-0x
Copy link
Collaborator

@lambda-0x lambda-0x commented Aug 28, 2024

Summary by CodeRabbit

  • New Features

    • Improved event processing logic for better handling of unprocessed events.
    • Enhanced clarity in the logging mechanism for unprocessed events, consolidating logs for efficiency.
  • Bug Fixes

    • Resolved issues related to immediate logging of unprocessed events, ensuring they are logged only once after processing.

Copy link

coderabbitai bot commented Aug 28, 2024

Walkthrough

Ohayo, sensei! The changes to the Engine implementation introduce a new control flow for handling unprocessed events. A boolean flag is used to track whether any processor has handled an event, with logging of unprocessed events occurring only after all processors have been evaluated. This streamlines the event processing logic.

Changes

Files Change Summary
crates/torii/core/src/engine.rs Introduced a boolean flag to track unprocessed events; refactored logging to occur after all processors are evaluated.

Sequence Diagram(s)

sequenceDiagram
    participant EventProcessor
    participant Processor

    EventProcessor->>Processor: Start processing events
    loop Check each processor
        Processor-->>EventProcessor: Validate event
        alt Event handled
            EventProcessor->>EventProcessor: Set unprocessed = false
        else Event not handled
            EventProcessor->>EventProcessor: Continue to next processor
        end
    end
    alt No processors handled the event
        EventProcessor->>EventProcessor: Log unprocessed event
    end
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e1a349b and 5c16c28.

Files selected for processing (1)
  • crates/torii/core/src/engine.rs (2 hunks)
Additional comments not posted (5)
crates/torii/core/src/engine.rs (5)

466-466: LGTM!

The initialization of the unprocessed flag is correct and aligns with the new control flow logic.

The code changes are approved.


474-474: LGTM!

The logic for setting the unprocessed flag is correct and ensures that the flag is only set to false if a processor handles the event.

The code changes are approved.


491-491: LGTM!

The check for the unprocessed flag after the loop is correct and aligns with the new control flow logic.

The code changes are approved.


492-496: LGTM!

The creation of the UnprocessedEvent struct is correct and aligns with the new control flow logic.

The code changes are approved.


497-504: LGTM!

The logging of the unprocessed event using the trace macro is correct and ensures that unprocessed events are logged only once, after all processors have been evaluated.

The code changes are approved.


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 as 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.

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

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 Aug 28, 2024

Codecov Report

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

Project coverage is 67.52%. Comparing base (e1a349b) to head (5c16c28).
Report is 2 commits behind head on main.

Files Patch % Lines
crates/torii/core/src/engine.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2352   +/-   ##
=======================================
  Coverage   67.51%   67.52%           
=======================================
  Files         359      359           
  Lines       46853    46858    +5     
=======================================
+ Hits        31634    31639    +5     
  Misses      15219    15219           

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

@glihm glihm merged commit 961b8c0 into main Aug 28, 2024
15 checks passed
@glihm glihm deleted the fix-unprocessed-event branch August 28, 2024 14:10
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