feat(tx-cache): add SSE subscription methods for transactions and orders#209
Draft
feat(tx-cache): add SSE subscription methods for transactions and orders#209
Conversation
Add subscribe_transactions() and subscribe_orders() behind an \`sse\` feature flag. These connect to the /transactions/feed and /orders/feed SSE endpoints and return typed streams that terminate on first error. Uses eventsource-stream as a lightweight, HTTP-client-agnostic SSE parser over reqwest byte streams. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Ensures HTTP error responses (404, 403, etc.) are correctly mapped to TxCacheError variants instead of surfacing as confusing SSE parse errors. Co-Authored-By: Claude Opus 4.6 <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.

Description
Add
subscribe_transactions()andsubscribe_orders()methods toTxCachebehind anssefeature flag. These connect to the/transactions/feedand/orders/feedSSE endpoints exposed by tx-pool-webservice and return typedStreams ofTxEnvelope/SignedOrderthat terminate on first error.Uses
eventsource-streamas a lightweight SSE parser over reqwest byte streams — no HTTP client coupling, minimal deps (futures-core,nom,pin-project-lite).Changes
Cargo.toml: Addeventsource-stream = "0.2.3"to workspace depstx-cache/Cargo.toml: Addssefeature gatingeventsource-stream,serde_json, andreqwest/streamtx-cache/src/error.rs: AddSseandDeserializationerror variants withFromimpls, all behind#[cfg(feature = "sse")]tx-cache/src/client.rs: Addsubscribe_inner<T>generic helper and two public async methods (subscribe_transactions,subscribe_orders)Design decisions
stream_*convention. Reconnection can be layered by the consumer.Related Issue
Closes ENG-1987
Testing
--all-featuresand--no-default-featurescargo +nightly fmtclean