Skip to content

feat: Add async hook, plugin, and flag tracker - #463

Merged
jsonbailey merged 6 commits into
mainfrom
jb/sdk-2737/async-hooks-plugins-tracker
Jul 27, 2026
Merged

feat: Add async hook, plugin, and flag tracker#463
jsonbailey merged 6 commits into
mainfrom
jb/sdk-2737/async-hooks-plugins-tracker

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Overview

This slice adds the async counterparts of the SDK's hook and plugin extension points, plus the async flag tracker used by the async client:

  • AsyncHook (ldclient/hook.py) — abstract base for async hooks. before_evaluation / after_evaluation are coroutines awaited by the async client.
  • AsyncPlugin (ldclient/plugin.py) — abstract base for async plugins. register() is a coroutine (allowing async initialization such as connecting to telemetry backends); get_hooks() remains synchronous and returns AsyncHook instances.
  • AsyncFlagTrackerImpl / AsyncFlagValueChangeListener (ldclient/impl/async_flag_tracker.py) — the async flag tracker implementation.

Unit tests are added in ldclient/testing/test_async_hooks.py and ldclient/testing/test_async_flag_tracker.py.

The async public classes carry the experimental .. caution:: block, matching the rest of the async surface.

This PR depends only on already-merged foundation work and can be reviewed independently.

Tracked internally: SDK-2737


Note

Low Risk
Additive experimental APIs and implementation behind the async client surface; no changes to sync evaluation paths, with behavior covered by new unit tests.

Overview
Adds experimental async extension points and flag-change tracking for AsyncLDClient, paralleling the sync Hook, Plugin, and FlagTracker APIs.

AsyncHook and AsyncPlugin introduce coroutine-based before_evaluation / after_evaluation and register(), with sync get_hooks() returning AsyncHook instances. New public types are marked with the experimental caution block.

AsyncFlagTracker (interface) and AsyncFlagTrackerImpl implement async per-flag value listeners: subscription awaits an initial evaluation for a baseline, re-evaluates on config changes, and notifies only when the value differs. Work is scheduled via AsyncCallbackScheduler so notifications from worker threads remain safe.

Docs clarify that AsyncReadOnlyStore is experimental and that BigSegmentStoreStatusProvider.status is non-blocking on the async client (available=False until the first background poll). Unit tests cover hook dispatch semantics and flag-tracker behavior, including cross-thread notify.

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

@jsonbailey
jsonbailey force-pushed the jb/sdk-2737/async-hooks-plugins-tracker branch from bc1d428 to f0bd132 Compare July 21, 2026 20:27
@jsonbailey
jsonbailey changed the base branch from jb/sdk-2729/async-big-segments to main July 21, 2026 20:27
@jsonbailey
jsonbailey force-pushed the jb/sdk-2737/async-hooks-plugins-tracker branch from f0bd132 to cc93fc2 Compare July 21, 2026 20:47
@jsonbailey
jsonbailey marked this pull request as ready for review July 21, 2026 21:19
@jsonbailey
jsonbailey requested a review from a team as a code owner July 21, 2026 21:19
Comment thread ldclient/impl/async_flag_tracker.py
@jsonbailey
jsonbailey force-pushed the jb/sdk-2737/async-hooks-plugins-tracker branch from cc93fc2 to 9869242 Compare July 21, 2026 21:37
Comment thread ldclient/impl/async_flag_tracker.py
Comment thread ldclient/impl/async_flag_tracker.py
Comment thread ldclient/impl/async_flag_tracker.py

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

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 733132b. Configure here.

Comment thread ldclient/impl/async_flag_tracker.py
@jsonbailey
jsonbailey merged commit 686a70a into main Jul 27, 2026
24 of 25 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-2737/async-hooks-plugins-tracker branch July 27, 2026 21:56
jsonbailey added a commit that referenced this pull request Jul 29, 2026
Adds the full `AsyncConfig` class to `ldclient/async_config.py`,
building on the previously-merged `AsyncBigSegmentsConfig` seed (#462).
This is a stacked-PR slice of the async Python SDK epic (SDK-60),
unblocked now that #463 merged `AsyncHook`/`AsyncPlugin`.

`AsyncConfig` mirrors the sync `Config` surface for the async client:
base/events/stream URIs, streaming vs. polling, event buffering, private
attributes, big segments, hooks, plugins, HTTP config, application
metadata, and the experimental data system config. The concrete
`AsyncEventProcessor` is imported only under `TYPE_CHECKING` to keep
aiohttp out of the runtime import graph.

This is self-contained and reviewable on its own. It unblocks the
upcoming async FDv1 polling (PR 7) and async event processor (PR 8),
both of which import the full `AsyncConfig`.

The public `AsyncConfig` (and `AsyncBigSegmentsConfig`) carry an
experimental `.. caution::` note — this API may change without notice
and is not yet production-ready.

Tracked internally: SDK-2768

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Large new experimental configuration surface touches networking,
events, and data-source wiring for the async client, though behavior is
additive and sync Config changes are limited to shared constants.
> 
> **Overview**
> Adds **`AsyncConfig`** in `ldclient/async_config.py` so
**`AsyncLDClient`** can be configured with the same knobs as sync
**`Config`**: endpoints, streaming/polling, events, privacy, big
segments, hooks/plugins, HTTP, payload filtering, and experimental
data-system settings. It wires in **`AsyncFeatureStore`** (default
**`AsyncInMemoryFeatureStore`**), **`AsyncHook`** / **`AsyncPlugin`**,
and factory hooks for **`AsyncUpdateProcessor`** and
**`AsyncEventProcessor`**, with experimental **`.. caution::`** on the
public API.
> 
> Sync **`Config`** now reuses shared **`DEFAULT_*_URI`** constants
instead of inline URL literals.
> 
> **`interfaces.py`** gains experimental **`AsyncUpdateProcessor`** and
**`AsyncEventProcessor`** (async **`stop`**, plus **`flush_and_wait`**
on the event processor) for upcoming async polling and event delivery.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3303a25. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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