feat: Add async FDv1 streaming and data source status tracking - #464
feat: Add async FDv1 streaming and data source status tracking#464jsonbailey wants to merge 6 commits into
Conversation
924244b to
485382a
Compare
485382a to
73977fd
Compare
| if self._data_source_update_sink is not None: | ||
| error_info = DataSourceErrorInfo(DataSourceErrorKind.UNKNOWN, 0, time.time(), str(e)) | ||
|
|
||
| self._data_source_update_sink.update_status(DataSourceState.INTERRUPTED, error_info) |
There was a problem hiding this comment.
Store error kind overwritten
Medium Severity
When the update sink reports STORE_ERROR and re-raises, the streaming processor's broad Exception handler calls update_status again with UNKNOWN. Because a new error is supplied, status is broadcast again and the more specific STORE_ERROR kind is replaced.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 73977fd. Configure here.
There was a problem hiding this comment.
This mirrors the sync data source status sink rather than being an async-only issue: sync's __monitor_store_update also re-raises after setting STORE_ERROR, and the sync streaming run() has the same broad except Exception that then calls update_status(INTERRUPTED, UNKNOWN) and overwrites the more specific kind. Keeping async in parity with sync here; if the overwrite is worth correcting it should be fixed in both sync and async as a separate change. Tracked as a follow-up.
Restore an async __monitor_store_update helper mirroring the sync sink, so the prior-data read during init() is monitored alongside store.init. A failure in that read now records STORE_ERROR and moves the status to INTERRUPTED, matching the sync data source status sink.
4149c47 to
89de1c5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 89de1c5. Configure here.
| from ldclient.versioned_data_kind import FEATURES, SEGMENTS | ||
|
|
||
|
|
||
| class AsyncStreamingUpdateProcessor(UpdateProcessor): |
There was a problem hiding this comment.
Wrong update processor base class
Medium Severity
AsyncStreamingUpdateProcessor subclasses sync UpdateProcessor instead of AsyncUpdateProcessor. That mismatches the async config factory contract and the async stop lifecycle (UpdateProcessor.stop is synchronous), so type checks and any isinstance/interface consumers treat this processor as the sync variant.
Reviewed by Cursor Bugbot for commit 89de1c5. Configure here.


Overview
Adds the async FDv1 streaming data source and its companion async data source status tracking, plus a new shared sans-I/O
datasource_commonmodule. This is one slice of the async Python SDK work.What's included
Async FDv1 streaming data source (
ldclient/impl/datasource/async_streaming.py) — driven byld_eventsource'sAsyncSSEClientand owning its ownaiohttpsession viamake_client_session. It consumes SSEput/patch/deleteevents and pushes the resulting data into the async data source update sink.Async data source status tracking (
ldclient/impl/datasource/async_status.py—AsyncDataSourceUpdateSinkImpland friends). The streaming source pushes data and status transitions into this update sink, so the two are runtime-coupled and land together in this slice.New shared sans-I/O
datasource_commonmodule (ldclient/impl/datasource/datasource_common.py) —STREAM_ALL_PATH,sink_or_store, andparse_path. Both the sync data sources and the new async streaming source use it.Behavior-preserving extraction of the sync data sources.
streaming.pyandpolling.pyare routed throughdatasource_common: the inline_sink_or_store/_parse_path/STREAM_ALL_PATH/ParsedPathdefinitions are removed in favor of importing the shared helpers, with call sites switched accordingly. No behavior change. The shared module is also needed by the upcoming async polling slice.Unified status provider (sync/async). The async status provider was unified with the sync one: the redundant
AsyncDataSourceStatusProviderImpl(which had no async-specific behavior — byte-identical to the sync provider apart from its sink type) is removed, and the async data system now reuses the syncDataSourceStatusProviderImpl. To let both sinks satisfy it structurally, the sync provider'supdate_sinkparameter was widened to a small status-onlyProtocol(_DataSourceStatusSource). This is the same interface-segregation pattern as the PR 1b config read-protocols and mirrors the already-unified big-segment status provider. This adds a small behavior-preserving change to syncstatus.py.Notes
.. caution::block.Tracked internally: SDK-2743
Note
Medium Risk
Touches live flag-ingestion paths (streaming, store versioning, change listeners) in new experimental async code; sync changes are mostly shared-helper extraction with interface widening for status providers.
Overview
Introduces async FDv1 streaming via
AsyncStreamingUpdateProcessor, which consumes SSEput/patch/deleteevents, reports data-source status, and writes through the configured update sink (with optional ownedaiohttpsession lifecycle).Adds
AsyncDataSourceUpdateSinkImplfor async store updates, dependency tracking, status broadcasts, and flag-change notifications—only when the async store actually applies an upsert/delete (stale versions are ignored).AsyncFeatureStore.deletenow returns a bool (mirroring upsert) so the async sink can skip listener noise on rejected deletes; the in-memory async store implements this.Extracts
datasource_common(STREAM_ALL_PATH,sink_or_store,parse_path) and wires sync streaming and polling through it without intended behavior changes.Unifies status reporting by typing
DataSourceStatusProviderImplagainst a small_DataSourceStatusSourceprotocol so sync and async sinks share one provider.Includes broad async unit tests for the sink and streaming processor (mock SSE, errors, session ownership).
Reviewed by Cursor Bugbot for commit 52de7f6. Bugbot is set up for automated code reviews on this repo. Configure here.