Add --memory-limit, signal handling and graceful_max_execution to rabbitmq:rpc-server#747
Open
qwant50 wants to merge 3 commits into
Open
Add --memory-limit, signal handling and graceful_max_execution to rabbitmq:rpc-server#747qwant50 wants to merge 3 commits into
qwant50 wants to merge 3 commits into
Conversation
…max_execution Makes the RPC server a first-class consumer: RpcServerCommand now extends BaseConsumerCommand, and the consume/memory/graceful-execution machinery moves from Consumer into BaseConsumer so RpcServer inherits it. Closes php-amqplib#746. Supersedes php-amqplib#524. Refs php-amqplib#712, php-amqplib#457.
When the memory limit was already exceeded at the top of the consume() loop, maybeStopConsumer() cancelled the consumer but wait() was still entered and could block forever (timeout 0 with no idle_timeout set). Raise the force-stop flag as well, so the loop skips wait() and returns. Also covers the relocated memory check with Consumer/DynamicConsumer tests and reformats the new README paragraph.
…argument BaseConsumerCommand labels its argument 'Consumer Name', which read oddly in 'rabbitmq:rpc-server --help'. Override it back to 'Server Name'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #746. Supersedes #524. Refs #712, #457, #545.
Makes the RPC server a first-class consumer:
RpcServerCommandnow extendsBaseConsumerCommand, inheriting--memory-limit|-l,--without-signals|-wand graceful SIGTERM/SIGINT/SIGQUIT handling.Consumerup intoBaseConsumer(verbatim), soRpcServerinherits it. The memory check now lives inmaybeStopConsumer(), one enforcement point for all consumer variants.rpc_serversconfig gainsidle_timeout,idle_timeout_exit_code,timeout_waitandgraceful_max_execution.Consumer→BaseConsumer(BC-safe widening).Fixes over #524: memory limit was never actually enforced on the RPC path;
graceful_max_executionwas wired in the extension but missing fromConfiguration.php(config would be rejected); event constructors type-hinted concreteConsumerand would TypeError;execute()lacked the int return; SIGQUIT was missing.BC notes: RPC loop switches
start()→consume()(dispatches OnConsume/OnIdle events, honors idle timeout;start()kept for programmatic users).--debugbecomes a flag (VALUE_NONE).--routeand--without-signalsnewly inherited (defaults preserve old behavior). SIGTERM now finishes the current message before exiting. The memory-limit check moved intomaybeStopConsumer(), so it now also runs between messages: an idle consumer over the limit stops on the next loop tick instead of only after processing a message (the force-stop flag is raised so the loop exits cleanly rather than re-enteringwait()). Important for existing listeners:on_consume/on_idleevents can now carry anRpcServerinstance where previously onlyConsumerwas possible — if a listener callsConsumer-only methods (purge(),delete()) on$event->getConsumer()without aninstanceof Consumerguard, it will now fatal the first time it fires for an RPC server.Tests: memory-limit stop behavior in RpcServerTest, new RpcServerCommandTest for the input definition, DI wiring fixture + assertions for the new rpc_servers options. Full suite + PHPStan pass; README updated.