Add Inline queue adapter that runs jobs on enqueue - #146
Draft
eldadfux wants to merge 3 commits into
Draft
Conversation
Add a transport that is also a Publisher: start() arms Server jobs and returns, and enqueue() invokes the matching handler in the same process. This lets a single HTTP or CLI process handle side effects without a broker or worker container. Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
Failed jobs called reject() on Adapter::$queue, which consume() never binds. Drive processFrom() with the enqueue queue, and assert start() returns the Server. Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
3 tasks
Handlers must see plain arrays after enqueue, matching Redis/Nats. Convert Documents, stdClass, and nested objects before processFrom so Appwrite workers need no Document-vs-array special cases. Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
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.
What
Adds
Adapter\Inline: a queue adapter that is also the publisher.enqueue()runs the matchingjob()in the same process and returns when the handler finishes.start()arms those handlers and returns — there is no consume loop and no worker process.Use this when a single process should handle HTTP (or CLI) and its side-effects without a broker.
Behavior
enqueue()still returnstrue(same as a broker that accepted the message)getQueueSize()is always0;retry()is a no-opServer::start()rejects a shared Consumer — Inline passes a callable factory so it can register many jobsprocessFrom()soprocess()does not read the uninitialized$this->queuepropertyDocument/stdClassobjects. Empty objects become[]. This keeps Appwrite workers adapter-agnostic.Companion Appwrite change: appwrite/appwrite#13269 (
_APP_QUEUE_ADAPTER=inline, no worker containers).Test Plan
vendor/bin/phpunit packages/queue/tests/Queue/Unit/InlineAdapterTest.php(11 tests) on PHP 8.3composer testis not run here: other queue unit files use PHP 8.5 syntax this host cannot parse