-
Notifications
You must be signed in to change notification settings - Fork 280
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
feat: add disconnect() method to release resources deterministically #290
Conversation
I like the idea; when tests pass I'll merge this. |
81253a5
to
3f4752d
Compare
3f4752d
to
8fd247c
Compare
Introduces the disconnect() method to ensure that all associated resources are released when closing a connection. This guarantees that no resources remain allocated, allowing garbage collection to reclaim memory safely. If no connection is open, the method is a noop. Future command dispatches will automatically establish a new connection if needed. This is necessary to avoid potential resource leaks and to ensure deterministic behavior when closing a connection. In Beanstalk released jobs are immediately enqueued when the connection is closed. This means that even if we do not care about potential memory leaks, we still want to control when exactly the connection is closed to avoid unintended side effects.
8fd247c
to
3453942
Compare
This is a break in BC, it means we need a major release. (Since we add a method to the interface, which other implementations don't have and therefore their code would break). |
If we want to delay a mayor release I could also do something like #291 for v6 and we will add it to the interface later in v7. |
I don't mind a major release; it's the correct thing. But need to make sure it's properly tagged, I think I can do that in the merge commit message. |
On second thought: this disconnect should be on all interfaces. Even if you are just publishing you might want to disconnect etc. |
@SplotyCode could you add the |
Moved the disconnect() method from PheanstalkManagerInterface to a new PheanstalkClientInterface. The interfaces PheanstalkSubscriberInterface, PheanstalkManagerInterface, and PheanstalkPublisherInterface now extend PheanstalkClientInterface, ensuring a consistent API for all client-related operations. This refactoring improves interface segregation by grouping shared functionality (and documentation) while keeping specific responsibilities separate.
31ef85b
to
0ede631
Compare
This is OK! I will merge it, don't bother fixing the check it's not your fault. |
Looks like phpunit/phpunit 12.0.9 is incompatible with phpstan/phpstan-phpunit 2.0.4. With phpunit/phpunit 12.0.8 it worked. From my understanding the ci error is unrelated to the changes in this pr |
🎉 This PR is included in version 7.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Ah, I didn't see your comment. Thanks for the heads-up! We can temporarily force a lower PHPUnit version with |
No need, the extension causing the issue is no longer needed for this project! |
Introduces the close() method to ensure that all associated resources are released when closing a connection. This guarantees that no resources remain allocated, allowing garbage collection to reclaim memory safely. If no connection is open, the method is a noop. Future command dispatches will automatically establish a new connection if needed.
This is necessary to avoid potential resource leaks and to ensure deterministic behavior when closing a connection. In Beanstalk released jobs are immediately enqueued when the connection is closed. This means that even if we do not care about potential memory leaks, we still want to deterministic control when exactly the connection is closed.