Skip to content

feat: Add async FDv1 streaming and data source status tracking - #464

Merged
jsonbailey merged 13 commits into
mainfrom
jb/sdk-2743/async-fdv1-streaming
Aug 4, 2026
Merged

feat: Add async FDv1 streaming and data source status tracking#464
jsonbailey merged 13 commits into
mainfrom
jb/sdk-2743/async-fdv1-streaming

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds the async FDv1 streaming data source and its companion async data source status tracking, plus a new shared sans-I/O datasource_common module. 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 by ld_eventsource's AsyncSSEClient and owning its own aiohttp session via make_client_session. It consumes SSE put/patch/delete events and pushes the resulting data into the async data source update sink.

  • Async data source status tracking (ldclient/impl/datasource/async_status.pyAsyncDataSourceUpdateSinkImpl and 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_common module (ldclient/impl/datasource/datasource_common.py) — STREAM_ALL_PATH, sink_or_store, and parse_path. Both the sync data sources and the new async streaming source use it.

  • Behavior-preserving extraction of the sync data sources. streaming.py and polling.py are routed through datasource_common: the inline _sink_or_store/_parse_path/STREAM_ALL_PATH/ParsedPath definitions 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 sync DataSourceStatusProviderImpl. To let both sinks satisfy it structurally, the sync provider's update_sink parameter was widened to a small status-only Protocol (_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 sync status.py.

Notes

  • The async public class carries the experimental .. caution:: block.
  • No CHANGELOG entries or version bumps (handled at release time).

Tracked internally: SDK-2743


Note

Medium Risk
Touches core flag data ingestion (streaming, store versioning, change notifications) for the new async path; sync changes are mostly refactors to shared helpers plus a widened status-provider type.

Overview
Adds async FDv1 streaming (AsyncStreamingUpdateProcessor) and AsyncDataSourceUpdateSinkImpl so SSE put/patch/delete updates flow through the async feature store with status and flag-change notifications, mirroring the sync stack.

Introduces datasource_common (STREAM_ALL_PATH, sink_or_store, parse_path, polling endpoint constant) and wires sync streaming/polling/feature requester through it instead of duplicated helpers—no intended behavior change on the sync path.

Async store contract: AsyncFeatureStore.delete now returns whether the delete was applied; the async sink only updates dependency tracking and flag listeners when upsert/delete actually write, avoiding spurious events on stale versions.

Status provider: DataSourceStatusProviderImpl accepts a small _DataSourceStatusSource protocol so one provider works with sync and async sinks.

Async streaming owns an aiohttp session built lazily in _run via make_client_session when no SSE factory is injected, with teardown on stop/errors; extensive tests cover streaming, status sink, and session lifecycle.

Reviewed by Cursor Bugbot for commit a32fc16. Bugbot is set up for automated code reviews on this repo. Configure here.

@jsonbailey
jsonbailey marked this pull request as ready for review July 27, 2026 20:38
@jsonbailey
jsonbailey requested a review from a team as a code owner July 27, 2026 20:38
Comment thread ldclient/impl/datasource/async_streaming.py
Comment thread ldclient/impl/datasource/async_status.py Outdated
@jsonbailey
jsonbailey force-pushed the jb/sdk-2743/async-fdv1-streaming branch from 924244b to 485382a Compare July 27, 2026 21:32
Comment thread ldclient/impl/datasource/async_status.py Outdated
@jsonbailey
jsonbailey force-pushed the jb/sdk-2743/async-fdv1-streaming branch from 485382a to 73977fd Compare July 27, 2026 22:00
Comment thread ldclient/impl/datasource/async_streaming.py Outdated
@jsonbailey
jsonbailey force-pushed the jb/sdk-2743/async-fdv1-streaming branch from 4149c47 to 89de1c5 Compare July 29, 2026 19:31
Comment thread ldclient/impl/datasource/async_streaming.py Outdated
Comment thread ldclient/impl/datasource/async_streaming.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Fix All in Cursor

❌ 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 c7f3f28. Configure here.

Comment thread ldclient/impl/datasource/async_streaming.py Outdated
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.
Its stop() is a coroutine, so it must implement the async update processor
interface rather than the sync UpdateProcessor (whose stop is synchronous).
Share the FDv1 polling endpoint from the sans-I/O datasource_common module
(next to STREAM_ALL_PATH) so the sync and async feature requesters no longer
each define their own copy.
Defer creating the owned aiohttp session + SSE factory from __init__ to _run(),
so the ClientSession is created on the running event loop (aiohttp's
expectation) rather than at construction time. Behavior is unchanged when a
factory is injected.
The async streaming processor builds its own aiohttp session in _run when no factory is injected, but only closed it on a normal loop exit or via stop(). If a later step raised — create(), the SSE iterator, or interrupt() — the exception escaped _run with no finally and the session leaked. Wrap the stream body in try/finally so the owned session is always closed.
@jsonbailey
jsonbailey force-pushed the jb/sdk-2743/async-fdv1-streaming branch from 21e1e09 to 5c7185e Compare August 4, 2026 16:32
Comment thread ldclient/impl/datasource/async_streaming.py
Comment thread ldclient/impl/datasource/async_streaming.py Outdated
Comment thread ldclient/impl/datasource/async_streaming.py Outdated
The FDv1 streaming processors logged the raw, server-provided path on an unrecognized patch/delete path. No other LaunchDarkly SDK logs the raw path (Go/Java/JS ignore it silently, .NET logs a path-free message), so drop the interpolated value from both the sync and async warnings. FDv2 has no such log.
@jsonbailey
jsonbailey requested a review from joker23 August 4, 2026 18:37
@jsonbailey
jsonbailey merged commit 4bf7067 into main Aug 4, 2026
24 of 25 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-2743/async-fdv1-streaming branch August 4, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants