Skip to content

feat: Add async migrations - #470

Open
jsonbailey wants to merge 3 commits into
mainfrom
jb/sdk-2767/async-migrations
Open

feat: Add async migrations#470
jsonbailey wants to merge 3 commits into
mainfrom
jb/sdk-2767/async-migrations

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Adds the async migration surface for the async Python SDK — AsyncMigrator, AsyncMigratorBuilder, AsyncMigrationConfig, and the AsyncMigratorFn type — in ldclient/migrations/async_migrator.py, eagerly exported from ldclient/migrations/__init__.py (import-cheap: asyncio stdlib only, no aiohttp).

Also carries the migration config/builder dedup shared by the sync and async surfaces: types.py gains _MigrationConfigBase[_MigratorFnT] (Generic) and _MigratorBuilderBase (fluent-setter mixin), and migrator.py's MigratorBuilder is re-based onto that mixin. These are behavior-preserving refactors of already-released sync code.

The public async classes carry experimental .. caution:: blocks.

Self-contained: depends only on already-merged foundation work. The AsyncLDClient/Context references are TYPE_CHECKING-only (annotations kept lazy via from __future__ import annotations); no runtime import of any not-yet-merged async module.

No CHANGELOG or version changes (handled at release).

Tracked internally: SDK-2767


Note

Medium Risk
New experimental dual-read/write migration paths can affect customer data routing when adopted; sync builder refactor is low-risk but touches released migration APIs.

Overview
Adds an experimental async migration API (AsyncMigrator, AsyncMigratorBuilder, AsyncMigrationConfig, AsyncMigratorFn) that mirrors the sync migrator: flag-driven stages, old/new coroutine hooks, dual-read consistency checks, and track_migration_op telemetry. Reads can run in parallel via asyncio.gather (vs threads on sync).

Sync refactor: fluent builder options (read_execution_order, track_latency, track_errors) move to _MigratorBuilderBase in types.py; MigratorBuilder subclasses it with unchanged behavior. New symbols are eagerly exported from ldclient.migrations (stdlib-only import path).

Broad test_async_migrator.py coverage aligns with existing sync migrator tests (stages, tracking, execution order).

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

@jsonbailey
jsonbailey force-pushed the jb/sdk-2767/async-migrations branch from abe7dac to c735e0e Compare July 27, 2026 22:01
@jsonbailey

Copy link
Copy Markdown
Contributor Author

@cursor review

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c735e0e. Configure here.

@jsonbailey
jsonbailey force-pushed the jb/sdk-2767/async-migrations branch from c735e0e to ec7746a Compare July 29, 2026 19:31
…ic base

Drop _MigrationConfigBase and give MigrationConfig and AsyncMigrationConfig
their own bodies. The shared base saved only a few trivial passthrough
properties while adding generic indirection, and full duplication matches how
Config/AsyncConfig are handled. MigrationConfig reverts to its pre-async
standalone form.
@jsonbailey
jsonbailey marked this pull request as ready for review July 30, 2026 21:59
@jsonbailey
jsonbailey requested a review from a team as a code owner July 30, 2026 21:59
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.

1 participant