Skip to content

Convert envelope trait to abstract class #231

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

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

viktorprogger
Copy link
Contributor

No description provided.

@viktorprogger viktorprogger self-assigned this Dec 15, 2024
@viktorprogger viktorprogger mentioned this pull request Dec 15, 2024
@@ -37,12 +37,4 @@ public function getMetadata(): array
{
return $this->metadata;
}

public function withMetadata(array $metadata): self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

@viktorprogger viktorprogger May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any real-world use cases. Do you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message handlers may add metadata into the message

Copy link
Contributor Author

@viktorprogger viktorprogger Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should wrap it into an envelope then.

@@ -23,14 +20,6 @@ public function getMessage(): MessageInterface
return $this->message;
}

public function withMessage(MessageInterface $message): self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

@viktorprogger viktorprogger May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any real-world use cases. Do you?

Copy link
Contributor Author

@viktorprogger viktorprogger Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question.
Why is this better than FooEnvelope::fromMessage($message) or new FooEnvelope()?

Copy link

codecov bot commented May 4, 2025

Codecov Report

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

Project coverage is 96.47%. Comparing base (7ac5da4) to head (209ba7b).

Files with missing lines Patch % Lines
src/Message/Envelope.php 96.29% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #231      +/-   ##
============================================
+ Coverage     96.16%   96.47%   +0.30%     
+ Complexity      359      356       -3     
============================================
  Files            47       47              
  Lines           966      965       -1     
============================================
+ Hits            929      931       +2     
+ Misses           37       34       -3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@viktorprogger viktorprogger requested a review from xepozz May 8, 2025 11:25
@viktorprogger viktorprogger requested a review from samdark May 9, 2025 16:13
Copy link
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, this PR significantly degraded performance (see benchmark CI).

@samdark
Copy link
Member

samdark commented May 13, 2025

The performance concern is valid.

@@ -37,12 +37,4 @@ public function getMetadata(): array
{
return $this->metadata;
}

public function withMetadata(array $metadata): self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message handlers may add metadata into the message

@@ -29,21 +23,4 @@ public function testFromData(): void
$this->assertArrayHasKey('meta', $envelope->getMetadata());
$this->assertSame('data', $envelope->getMetadata()['meta']);
}

public function testWithMessage(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep it

Copy link
Contributor Author

@viktorprogger viktorprogger Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this better than FooEnvelope::fromMessage($message) or new FooEnvelope()?

@viktorprogger
Copy link
Contributor Author

@samdark @vjik Envelope stack creation slowdown was fixed here.
My local bench result comparing to master:
image

@samdark
Copy link
Member

samdark commented Jul 14, 2025

@viktorprogger benchmark is looking way better now. How about merging master into the PR branch?

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.

5 participants