Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Use newer version of Beanstalkd bridge library#60040

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:7.3fromHypeMC:beanstalk-5
Mar 26, 2025

Conversation

HypeMC
Copy link
Member

QA
Branch?7.3
Bug fix?no
New feature?no
Deprecations?no
Issues-
LicenseMIT

Currently, the Beanstalkd bridge supports version 4 ofpda/pheanstalk, which is no longer maintained. The latest version is v7, and the actively maintained versions appear to be v5 and v7. Version 7 was released just a week after v6, and from what I can tell, v6 is not supported as no patch versions have ever been released for it.

This PR bumps support to the maintained versions. I've split it into two commits to make reviewing easier:

  1. The first commit upgrades the library version and updates the code for compatibility.
  2. The second commit adds a reconnect mechanism. Version 4 had abuilt-in one, which was removed in v5+. This commit reimplements that logic in theConnection class.

I'm not sure which version of Symfony this should target. It's not exactly a new feature, but the changes are significant.

OskarStark reacted with thumbs up emoji
"pda/pheanstalk":"^4.0",
"pda/pheanstalk":"^5.1|^7.0",
Copy link
MemberAuthor

@HypeMCHypeMCMar 25, 2025
edited
Loading

Choose a reason for hiding this comment

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

These are the versions that have thedisconnect() method, which is needed for the reconnect mechanism. Also, v7 supports only PHP 8.3+, while v5 supports PHP 8.1+.

Comment on lines 172 to 186
return$this->client->watchOnly($this->tube)->reserveWithTimeout($this->timeout);
if ($this->client->watch($this->tube) >1) {
foreach ($this->client->listTubesWatched()as$tube) {
if ((string)$tube !== (string)$this->tube) {
$this->client->ignore($tube);
}
}
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

ThewatchOnly method was removed, this implements similar behavior.

Comment on lines 137 to 142
$job =$this->client->useTube($this->tube)->put(
$this->client->useTube($this->tube);
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Some methods likeuseTube are no longer chainable.

@@ -503,3 +517,7 @@ public function testSendWithRoundedDelay()
$connection->send($body,$headers,$delay);
}
}

interface PheanstalkInterfaceextends PheanstalkPublisherInterface, PheanstalkSubscriberInterface, PheanstalkManagerInterface
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

ThePheanstalkInterface was split into multiple interfaces. Since the client implements all of them, it's hard to mock. This is a helper interface to make mocking easier.

try {
return$command();
}catch (ConnectionException) {
$this->client->disconnect();
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not sure what to do about the Psalm errors. Even though thedisconnect() method wasn't added to the interfaces in v5 (to avoid BC breaks), it was added to thePheanstalk class itself, which is what's used here, so the method always exists. I could usemethod_exists(), but that feels redundant. The method was added to the interfaces in v7, but that version requires PHP 8.3.

@fabpot
Copy link
Member

Thank you@HypeMC.

@fabpotfabpot merged commite282c2f intosymfony:7.3Mar 26, 2025
4 of 11 checks passed
@HypeMCHypeMC deleted the beanstalk-5 branchMarch 26, 2025 09:46
@fabpotfabpot mentioned this pull requestMay 2, 2025
fabpot added a commit that referenced this pull requestMay 8, 2025
…alk (HypeMC)This PR was merged into the 7.3 branch.Discussion----------[Messenger] Fix integration with newer versions of Pheanstalk| Q             | A| ------------- | ---| Branch?       | 7.3| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        | -| License       | MITFollow-up to#60040.When I updated the Pheanstalk library, I missed the fact that version 4 internally tracked the [used](https://github.com/pheanstalk/pheanstalk/blob/1459f2f62dddfe28902e0584708417dddd79bd70/src/Pheanstalk.php#L316-L324)/[watched](https://github.com/pheanstalk/pheanstalk/blob/1459f2f62dddfe28902e0584708417dddd79bd70/src/Pheanstalk.php#L329-L337) tube. This was removed in newer versions, so now every call to `useTube()` or `watch()` sends a command to Beanstalkd, leading to unnecessary bandwidth consumption.This PR adds simple tracking logic to avoid redundant calls to those functions.Commits-------b766607 [Messenger] Fix integration with newer version of Pheanstalk
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

3 participants
@HypeMC@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp