refactor(client): route cancel_timer/fetch_unprocessed through the client seam#141
Merged
Merged
Conversation
…ient seam Both broker methods built delete()/select() inline on self._outbox_table, bypassing the OutboxClient seam that already owns the table -- so table/column knowledge was split across producer, client, and broker-inline. Move them onto AbstractOutboxClient (real + fake) so the client is the single owner of that SQL; the broker methods become thin delegations. - guards live in the client adapters (matches how publish validates): the real client raises TypeError/ValueError, the fake ignores session and mirrors the limit guard; the broker delegation is a pure passthrough - fetch_unprocessed co-locates with _row_to_message, so broker.py drops the delete/select/_row_to_message imports - delete the test-broker patch machinery for both: the test broker already swaps in the fake as broker.client, so delegation reaches it (publish/publish_batch stay patched -- they drive sync dispatch) Behavior change (deliberate): the test broker's session arg goes from runtime-optional to required-but-ignored, aligning runtime with the always- required type and the documented public signature. No documented usage omitted it. Truth-home promotion in architecture/test-broker.md + docs/usage/testing.md. Full suite green (599 passed, coverage 100%), just lint + ty + check-planning + mkdocs --strict clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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
Moves
cancel_timerandfetch_unprocessedoff the broker's inline SQL and onto theAbstractOutboxClientseam, so the client is the single owner of outbox-table SQL. The broker methods become thin delegations.From the architecture-deepening review (candidate #3). Previously table/column knowledge was split three ways — producer (insert+NOTIFY), client (lease/DLQ), and broker-inline (
delete(t)/select(*t.c)onself._outbox_table). Now it lives behind one seam.Changes
client.py— two new methods onAbstractOutboxClient+OutboxClientimpls (SQL + both input guards moved verbatim).fetch_unprocessedco-locates with_row_to_message.publishvalidates. Real client raisesTypeError/ValueError; fake ignoressession(del session) and mirrors the limit guard. A directly-constructedOutboxClientnow enforces the contract itself.broker.py— both methods reduced toreturn await self.client.<method>(...); drops thedelete/select/_row_to_messageimports.testing.py—FakeOutboxClientgainsfetch_unprocessedand an alignedcancel_timer; the_build_fake_cancel_timer/_build_fake_fetch_unprocessedbuilders + their twomock.patch.objectlines are deleted — the test broker already swaps in the fake asbroker.client, so delegation reaches it. (publish/publish_batch stay patched — they drive sync dispatch.)Behavior change (deliberate)
The test broker's
sessionarg goes from runtime-optional (the deleted patch defaulted it toNone) to required-but-ignored, matching the client signature. This aligns runtime with what was always true at the type level (old test calls carried# ty: ignore[missing-argument]) and with the documented public signature (docs/usage/timers.md). No documented usage omittedsession.Promotion
architecture/test-broker.md+docs/usage/testing.mdupdated (the two methods delegate through the swapped fake client; session required). Lightweight change file added.Verification
just test— 599 passed, Postgres 17, coverage 100.00%just lint— ruff + ty cleanjust check-planning— OKmkdocs build --strict— clean🤖 Generated with Claude Code