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

Update Invoker to handle Message objects as input #25

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

butschster
Copy link
Contributor

@butschster butschster commented Nov 30, 2023

Now it can accept both string and Message objects as inputs. This change simplifies the process when the input is already a Message object, eliminating the need to convert it again.

Q A
Breaks BC?
New feature? ✔️
Issues spiral/roadrunner-bridge#90

Summary by CodeRabbit

  • New Features

    • Enhanced input handling in the invoke method to support Message objects directly.
  • Bug Fixes

    • Fixed string formatting issues with added commas in assertResultType and assertInputType methods.
  • Tests

    • Added a new test testInvokeWithInputMessage to ensure proper handling of Message objects.
    • Improved testInvokeError with additional assertions for exception handling.
    • Introduced a packMessage utility method for test message preparation.
    • Updated createMessage method to return Message objects for testing purposes.

Now it can accept both string and Message objects as inputs. This change simplifies the process when the input is already a Message object, eliminating the need to convert it again.
@butschster butschster added the enhancement New feature or request label Nov 30, 2023
@butschster butschster self-assigned this Nov 30, 2023
Copy link

coderabbitai bot commented Nov 30, 2023

Walkthrough

The Invoker class has been updated to handle a new type of input parameter, allowing for either a string, a Message object, or null. The invoke method now directly uses a Message instance if provided, or creates one from the input. Minor formatting changes were made to two methods, adding commas for string formatting. The test suite has been expanded with a new test for invoking with a Message and updated to include more detailed assertions for error handling.

Changes

File Path Change Summary
src/Invoker.php Updated invoke method to accept `string
tests/InvokerTest.php Added testInvokeWithInputMessage test; updated testInvokeError with more assertions; added packMessage method; modified createMessage to return Message object.

🐇✨
In the code where bytes dance and twirl,
A rabbit hopped, made changes unfurl.
With tests and types in harmonious swirl,
It crafted a patch, a digital pearl. 🌟
🐇✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

@codecov-commenter
Copy link

Codecov Report

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

Comparison is base (94b5ec7) 76.58% compared to head (00cd2f6) 76.67%.

Files Patch % Lines
src/Invoker.php 60.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.x      #25      +/-   ##
============================================
+ Coverage     76.58%   76.67%   +0.09%     
- Complexity       94       95       +1     
============================================
  Files             8        8              
  Lines           252      253       +1     
============================================
+ Hits            193      194       +1     
  Misses           59       59              

☔ 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 94b5ec7 and 00cd2f6.
Files selected for processing (2)
  • src/Invoker.php (3 hunks)
  • tests/InvokerTest.php (2 hunks)
Additional comments: 9
src/Invoker.php (4)
  • 17-35: The update to the invoke method to handle string|Message|null types and the logic to use the Message instance directly if provided is a good enhancement for flexibility. Ensure that all usages of this method are updated to handle the new parameter types correctly.

  • 51-55: The addition of the comma after the sprintf function call in the assertResultType method is a minor syntax correction for code style consistency.

  • 92-96: The addition of the comma after the sprintf function call in the assertInputType method is a minor syntax correction for code style consistency.

  • 92-98: The assertInputType method correctly checks if the provided class is a subclass of Message, ensuring type safety for the input conversion process.

tests/InvokerTest.php (5)
  • 28-29: The summary does not mention the modification in the testInvoke method where packMessage is now used instead of createMessage. This change should be documented to maintain an accurate record of all changes.

  • 31-43: The new test testInvokeWithInputMessage correctly verifies that the Invoker can handle a Message object as input.

  • 46-48: The summary states that the testInvokeError method includes additional assertions for the exception message, but the hunk does not show these changes. This inconsistency should be addressed.

  • 58-60: The addition of the packMessage method is a useful utility for serializing Message objects to strings for testing purposes.

  • 63-68: The createMessage method has been refactored to return a Message object, aligning with the new functionality of the Invoker class to accept Message objects.

@butschster butschster merged commit 6865691 into 3.x Nov 30, 2023
@butschster butschster deleted the feature/invoker-input branch November 30, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants