Repository navigation
feat: add Redis Cluster support - #2886
Closed
fbartonoctopus wants to merge 9 commits into
Closed
fbartonoctopus wants to merge 9 commits into
fbartonoctopus wants to merge 9 commits into
Conversation
Allow redis-py 8.x which adds async RedisCluster pubsub support (PR redis/redis-py#3736, released in 8.0.0b1). Co-Authored-By: Oz <oz-agent@warp.dev>
Replace deprecated lib_name/lib_version kwargs with the new
driver_info=DriverInfo().add_upstream_driver('faststream', __version__)
API. This fixes DeprecationWarnings emitted by redis-py >= 7.4.0.
The CLIENT SETINFO LIB-NAME is now reported as
'redis-py(faststream_v{version})'.
Co-Authored-By: Oz <oz-agent@warp.dev>
Add ClusterConnectionState that creates a RedisCluster[bytes] client directly (RedisCluster manages its own per-node connection pools). Unsupported ConnectionPool params (db, socket_read_size, socket_type, retry_on_timeout, parser_class, encoder_class, decode_responses) are automatically filtered out. Driver identification uses driver_info on redis-py 8.x and falls back to lib_name/lib_version on 7.x for compatibility. Co-Authored-By: Oz <oz-agent@warp.dev>
Add RedisClusterBroker that connects via redis.asyncio.cluster.RedisCluster instead of redis.asyncio.client.Redis. Supports all subscription types (channels, streams, lists) with the same API as RedisBroker. The broker: - Accepts only cluster-compatible connection parameters - Filters out unsupported options (db, socket_read_size, etc.) - Uses ClusterConnectionState for connection management - Inherits publish/subscribe/request from RedisBroker unchanged Channel (PubSub) subscribers require redis-py >= 8.0.0. Streams and lists work with redis-py >= 5.0.0. Co-Authored-By: Oz <oz-agent@warp.dev>
Add TestRedisClusterBroker for testing RedisClusterBroker without a real Redis Cluster connection. Follows the same mock-connection pattern as TestRedisBroker. Co-Authored-By: Oz <oz-agent@warp.dev>
Add RedisClusterRouter that wraps RedisClusterBroker for use as a FastAPI StreamRouter. Mirrors RedisRouter's subscriber/publisher API with cluster-compatible connection parameters. Co-Authored-By: Oz <oz-agent@warp.dev>
Tests cover: - ClusterConnectionState: parameter filtering, max_connections default, initial state, client access guard - RedisClusterBroker: instantiation, connection state type, URL db filtering, subscriber/publisher registration - TestRedisClusterBroker: mock publish/subscribe on lists, streams, and channels Co-Authored-By: Oz <oz-agent@warp.dev>
Add a single-node Redis Cluster service to docker-compose.yaml on port 7000, with justfile commands for redis-cluster-up/stop/logs. Integration tests (marked @pytest.mark.connected) cover: - Cluster connection and ping - Stream publish/consume - List publish/consume - Stream consumer groups Co-Authored-By: Oz <oz-agent@warp.dev>
Add docs/docs/en/redis/cluster/index.md covering: - Basic usage with RedisClusterBroker - Supported subscription types and redis-py version requirements - Connection parameters reference - FastAPI integration with RedisClusterRouter - Testing with TestRedisClusterBroker - Docker Compose example for local development Update the Redis index page with a link to the cluster docs. Co-Authored-By: Oz <oz-agent@warp.dev>
|
|
This was referenced May 22, 2026
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.
Summary
Add
RedisClusterBrokerfor Redis Cluster deployments, resolving #1170.Uses
redis.asyncio.cluster.RedisClusterunder the hood so commands areautomatically routed to the correct cluster node — no more
MOVEDerrors.What's included
RedisClusterBroker— drop-in replacement forRedisBrokerwith cluster-compatible parametersClusterConnectionState— connection lifecycle usingRedisClusterdirectly (notConnectionPool)TestRedisClusterBroker— mock-connection testing utilityRedisClusterRouter— FastAPI integration with full@overloadsubscriber signaturesdriver_infomigration — existingConnectionStatemigrated from deprecatedlib_name/lib_versiontoDriverInfoAPISubscription type support
>= 5.0.0>= 5.0.0>= 8.0.0(async cluster pubsub, currently beta)redis-py 8.x compatibility
Analysed the breaking changes in redis-py 8.0.0b1/b2. Default
legacy_responses=Truepreserves RESP2-compatible response shapes — no impact on faststream's stream/list/channel
parsing. The
redisdependency upper bound is bumped from<8.0.0to<9.0.0.Closes
Closes #1170
Warp conversation · Implementation plan
Co-Authored-By: Oz oz-agent@warp.dev