Feat/async iterable iterator - #557
Merged
Merged
Conversation
…ator over Horizon SSE contract event
…ator over Horizon SSE contract event
…ator over Horizon SSE contract event
…ator over Horizon SSE contract event
|
@nafsonig Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Summary of Changes
We've successfully implemented the
streamEventsmethod for the VeriTix SDK that connects to Horizon SSE endpoints, which is much more efficient than the existing polling-based watchers. Here's what was done:1. Added new types to
src/types/index.tsVeriTixEventinterface: Represents a parsed contract event with properties:type: Event name/typeledger: Ledger sequence numbertimestamp: Unix timestamp (in seconds)topics: Array of event topicsdata: Decoded event dataStreamEventOptionsinterface: Configuration options for streaming:signal: AbortSignal for cancellationinitialBackoffMs: Initial reconnection backoff (default: 1000ms)maxBackoffMs: Maximum backoff (default: 30000ms)cursor: Start streaming from a specific cursorhistory: (reserved for future use)2. Implemented
streamEventsmethod insrc/client.tsThe method is an async generator (
async *) that returns anAsyncIterableIterator<VeriTixEvent>, following the same pattern as existing watchers likewatchEscrow. Key features:eventsourcepackage)VeriTixEventformat, following Stellar's Horizon API specifications3. Exported new types in
src/index.tsAdded
VeriTixEventandStreamEventOptionsto the public API exports so users can import them.Usage Example
The implementation is complete and meets all the requirements: it uses Horizon SSE for efficient event streaming, parses events into the correct format, auto-reconnects with exponential backoff, and supports cancellation via AbortSignal.
Closes
Closes #
Checklist
CHANGELOG.mdupdated under[Unreleased](required by CI ifsrc/changed — see CONTRIBUTING.md)npm run buildpassesnpm testpassesnpm run lintpasses