Skip to content

feat: Add async migrations - #470

Draft
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2767/async-migrations
Draft

feat: Add async migrations#470
jsonbailey wants to merge 1 commit 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 API affects migration read/write orchestration and dual-write behavior; sync builder refactor is intended behavior-preserving but touches released migration configuration code.

Overview
Adds an experimental async migration API (AsyncMigrator, AsyncMigratorBuilder, AsyncMigrationConfig, AsyncMigratorFn) that mirrors the sync migrator: flag-backed stage selection via await migration_variation, coroutine-based old/new read/write handlers, dual-origin reads with asyncio.gather for parallel execution, and synchronous track_migration_op after each operation. Public types are exported from ldclient.migrations with a cheap import path (stdlib asyncio only).

Refactors shared sync/async plumbing in types.py via _MigrationConfigBase and _MigratorBuilderBase; MigratorBuilder now inherits the mixin (fluent read_execution_order / track_latency / track_errors unchanged, attribute names normalized to _read_execution_order etc.).

Adds broad test_async_migrator.py coverage aligned with sync migrator tests (stages, tracking, consistency, exceptions, execution order).

Reviewed by Cursor Bugbot for commit c735e0e. 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
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