-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Proto payloads between RR and PHP Worker #23
Conversation
msmakouz
commented
Mar 11, 2024
•
edited
Loading
edited
Q | A |
---|---|
Bugfix? | ❌ |
Breaks BC? | ❌ |
New feature? | ✔️ |
Issues | roadrunner-php/issues#13 |
- Need to move API to stable, instead of V1BETA1
- Need to write unit tests
- Need to release API DTO: https://github.com/roadrunner-php/roadrunner-api-dto/tree/http-beta and fix composer.json
WalkthroughThe recent update introduces enhancements to the HTTP worker system, focusing on better handling of HTTP requests and responses. Key improvements include the introduction of HTTP DTO classes, a new Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 3.x #23 +/- ##
=============================================
+ Coverage 21.46% 53.55% +32.08%
- Complexity 61 72 +11
=============================================
Files 4 4
Lines 177 211 +34
=============================================
+ Hits 38 113 +75
+ Misses 139 98 -41 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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
Files ignored due to path filters (1)
composer.json
is excluded by:!**/*.json
Files selected for processing (2)
- src/HttpWorker.php (10 hunks)
- src/HttpWorkerInterface.php (1 hunks)
Additional comments: 7
src/HttpWorkerInterface.php (1)
- 29-31: The update to the
$headers
parameter in therespond
method enhances type safety and clarity, which is a positive change. Ensure that all classes implementingHttpWorkerInterface
are updated accordingly to match this new signature.src/HttpWorker.php (6)
- 8-11: New imports for HTTP DTO classes have been added to support proto payloads. Ensure these classes are used appropriately throughout the file and that their versions are compatible with the project's dependencies.
- 41-41: Introduced a new
isProto
static property to determine if the payload is in proto format. This approach is efficient for payload type checking but ensure thread safety and consistency across multiple requests.- 65-70: The
waitRequest
method now includes logic to handle proto payloads. Ensure that theRequestProto
class'smergeFromString
method correctly parses the payload header and thatrequestFromProto
accurately constructs aRequest
object from the proto message.- 163-200: The
requestFromProto
method constructs aRequest
object from a proto message. Verify that all fields are correctly mapped from the proto message to theRequest
object, especially considering type conversions and error handling for missing or malformed data.- 261-268: The
createRespondPayload
method has been modified to support creating payloads in proto format. Ensure that the conditional logic correctly determines when to use proto format and that the serialization to proto is accurate and efficient.- 271-277: The
isProtoPayload
method determines if the current payload is in proto format. This method relies onjson_validate
to check the format. Ensure that this approach reliably distinguishes between JSON and proto formats, considering potential edge cases.
There was a problem hiding this 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
Files ignored due to path filters (1)
composer.json
is excluded by!**/*.json
Files selected for processing (4)
- src/HttpWorker.php (10 hunks)
- tests/Unit/HttpWorkerTest.php (1 hunks)
- tests/Unit/PSR7WorkerTest.php (3 hunks)
- tests/Unit/StreamResponseTest.php (1 hunks)
Additional comments (3)
tests/Unit/PSR7WorkerTest.php (2)
- 3-3: Adding
declare(strict_types=1);
is a good practice for enforcing type safety in PHP files.- 13-13: Changing the
PSR7WorkerTest
class tofinal
is appropriate for test classes, as they typically should not be extended.tests/Unit/StreamResponseTest.php (1)
- 13-13: Changing the
StreamResponseTest
class tofinal
is appropriate for test classes, as they typically should not be extended.
@@ -10,15 +10,14 @@ | |||
use Spiral\RoadRunner\Tests\Http\Unit\Stub\TestRelay; | |||
use Spiral\RoadRunner\Worker; | |||
|
|||
class StreamResponseTest extends TestCase | |||
final class StreamResponseTest extends TestCase | |||
{ | |||
private TestRelay $relay; | |||
private Worker $worker; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider calling parent::tearDown()
in the tearDown
method to ensure compatibility with future versions of PHPUnit that might introduce teardown logic.
protected function tearDown(): void
{
unset($this->relay, $this->worker);
+ parent::tearDown();
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
protected function tearDown(): void | |
{ | |
unset($this->relay, $this->worker); | |
parent::tearDown(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- composer.json (2 hunks)
Additional Context Used
Additional comments not posted (2)
composer.json (2)
44-47
: The updates and additions to the dependencies in therequire
section are aligned with the PR objectives to enhance efficiency and performance through protocol buffers for payload handling. It's good to see that the versions specified allow for flexibility while ensuring compatibility with newer versions.
- The update to
spiral/roadrunner
to support versions^2023.3 || ^2024.1
is appropriate for ensuring compatibility with the latest features and fixes.- The update to
spiral/roadrunner-worker
to version^3.5
and the addition ofroadrunner-php/roadrunner-api-dto
at version^1.6
are crucial for the new feature implementation.- The addition of
symfony/polyfill-php83
is a thoughtful inclusion for ensuring compatibility with PHP 8.3 features across different PHP versions.
76-77
: The suggestion forext-protobuf
is a valuable addition, guiding users towards enhancing Protocol Buffers support. This aligns well with the PR's goal of introducing proto payload support and ensures users are aware of the optional but recommended extension to maximize performance.
composer.json
Outdated
@@ -72,7 +73,8 @@ | |||
"analyze": "psalm" | |||
}, | |||
"suggest": { | |||
"spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools" | |||
"spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools", | |||
"ext-protobuf": "Provides Protocol Buffers support" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be beneficial to include a recommendation about this extension in the documentation. It's important to emphasize that it impacts performance. Without this extension, JSON operates faster than Proto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (2)
- composer.json (2 hunks)
- src/HttpWorker.php (10 hunks)
Files skipped from review as they are similar to previous changes (2)
- composer.json
- src/HttpWorker.php