Repository navigation
refactor: DLQ CTE in Core, prebuilt publish INSERTs, drop dead code - #226
Merged
Merged
Conversation
Benchmark gate✅ gate passed
Gated (fails the build): |
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.
Cleanup items R1, R2 and R4 from the review. No tracking issue and no behaviour change.
R1: DLQ CTE in SQLAlchemy Core
_build_dlq_cte_stmtbuilt the DELETE-then-archive statement as an f-string. That neededformat_tablefor quoting and schema qualification, plus anoqa: S608. It's nowinsert(dlq).from_select(...)over adelete(...).returning(...).cte("deleted"). SQLAlchemy hoists the CTE to the top of the statement, which Postgres requires for a data-modifying CTE, and the SQL comes out the same as before. Because the row id, the lease token and the failure context are all bind parameters, the client builds the statement once in__init__and the compiled cache can reuse it. The existing schema-qualification, adversarial-name and DLQ column tests still pass. They now compile the stored statement.R2: prebuilt publish INSERTs
_do_publishbuilt a newinsert()orpg_insert().on_conflict_do_nothing()on every publish. The producer now builds four statements once: plain or timer upsert, each with or without the server-sideactivate_inexpression. The row values go in as execute parameters.activate_atis a plain parameter and needs no variant of its own.Median per-publish time over 1000 publishes in one transaction, against the docker Postgres (two runs each):
activate_intimer_idFour
test_broker_publish_*tests now read the values from the execute parameters instead of from the compiled statement.R4: dead code
max(0.0, lease_ttl_seconds)inOutboxClient.fetchandFakeOutboxClient.fetch:lease_ttl_secondsis validated as> 0at config time. Themax(0.0, delay_seconds)guards stay, because a user's retry strategy can return any delay.connect/disconnectonOutboxProducerandFakeOutboxProducer: nothing calls them.ProducerProtodoesn't declare them, and the broker setsproducer.serializerdirectly. The three tests that existed only to cover them are removed.Two R4 items stay because they aren't dead.
OutboxProducer._parser/_decoderare members ofProducerProto. The subscriber's_queuesproperty is read throughgetattrbybroker.pyandregistrator.py.Verification
just bench-checkpasses.ruffis clean,tyshows the same 6 diagnostics asmain, and the docs build.