feat: Add async big segment store manager and async Redis adapter#462
Open
jsonbailey wants to merge 6 commits into
Open
feat: Add async big segment store manager and async Redis adapter#462jsonbailey wants to merge 6 commits into
jsonbailey wants to merge 6 commits into
Conversation
Adds AsyncBigSegmentStoreManager, the async Redis-backed AsyncBigSegmentStore adapter, and Redis.async_big_segment_store(). Seeds async_config.py with the self-contained AsyncBigSegmentsConfig (the full AsyncConfig lands later). Bumps the redis dependency to >=4.2.0 (required by redis.asyncio).
Drop the max_connections=10 default (and the now-unneeded redis_opts copy) so the async store passes redis_opts straight to from_url, matching the sync store. The sync side removed this cap in #387 (it throttled connections under load); redis.asyncio otherwise defaults to an effectively-unlimited pool.
…egments_common Both big_segments.py and async_big_segments.py defined the class identically (bar one docstring word); move it to a shared module imported by both, matching the evaluator_common/client_common pattern.
Fold _hash_for_user_key, EMPTY_MEMBERSHIP, and is_stale (as a free function) into big_segments_common, imported by both big_segments.py and async_big_segments.py.
Drop the redundant EMPTY_MEMBERSHIP class attribute and reference the big_segments_common module constant directly instead of via self.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The async big-segments layer for the async Python SDK.
impl/async_big_segments.py—AsyncBigSegmentStoreManager(async twin of the sync manager: membership caching viaExpiringDict, status polling viaAsyncRepeatingTask) +BigSegmentStoreStatusProviderImpl.impl/integrations/redis/async_redis_big_segment_store.py— async Redis-backedAsyncBigSegmentStore(redis.asyncio).integrations/__init__.py— newRedis.async_big_segment_store(...)factory (local import of the adapter, soredisstays optional).async_config.py— seeded withAsyncBigSegmentsConfigonly (see below).testing/impl/test_async_big_segments.py(unit) +testing/integrations/test_async_redis.py(live-Redis integration, guarded byskip_database_tests).pyproject.toml— bumpsredisto>=4.2.0(theredis.asyncioAPI requires redis-py 4.2+).Note on
async_config.pyAsyncBigSegmentStoreManagerneedsAsyncBigSegmentsConfig, which lives inasync_config.py. The fullAsyncConfigisn't extractable yet (it importsAsyncHook/AsyncPlugin/AsyncEventProcessor, which land in later slices), so this PR seedsasync_config.pywith just the self-containedAsyncBigSegmentsConfig(it depends only on the already-mergedAsyncBigSegmentStore). A later slice grows the file withAsyncConfig— mirroring how the sync SDK keepsBigSegmentsConfigalongsideConfiginconfig.py.Why
Part of the async Python SDK (epic SDK-60). Depends on the async support classes (#451) and async interfaces/store (#457), both merged.
Validation
uv run pytest ldclient/testing --ignore=ldclient/testing/integrations— 1033 passed, 2 skippeduv run pytest ldclient/testing/impl/test_async_big_segments.py— 14 passeduv run mypy ldclient— clean; isort / pycodestyle — cleantest_async_redis.py) require a live Redis (run in CI); properly guarded byskip_database_tests.SDK-2729 (epic SDK-60).
Note
Medium Risk
Sync big-segment code moved to shared helpers (behavior should be unchanged), and the redis optional dependency minimum increases; the async path is experimental but will affect segment membership when wired into the async client.
Overview
Adds the experimental async Big Segments stack:
AsyncBigSegmentsConfig,AsyncBigSegmentStoreManager(membership cache, background status polling viaAsyncRepeatingTask, and an inline poll on the first membership lookup if the poller has not run yet), plusRedis.async_big_segment_store()backed byredis.asyncio.Sync
BigSegmentStoreManageris refactored to sharebig_segments_common(EMPTY_MEMBERSHIP, user-key hashing, staleness, andBigSegmentStoreStatusProviderImpl) with the async manager so behavior stays aligned without duplicating logic.pyproject.tomlraises the optional/devredisfloor to >=4.2.0 forredis.asyncio. Unit and live-Redis integration tests cover the new manager and adapter.Reviewed by Cursor Bugbot for commit e428549. Bugbot is set up for automated code reviews on this repo. Configure here.