forked from redis/redis-py
-
Notifications
You must be signed in to change notification settings - Fork 1
Cluster mode draft PR #2 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
barshaul
wants to merge
105
commits into
master
Choose a base branch
from
cluster-mode
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 19 commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
cfb0ed8
Added support for cluster mode
barshaul 942b35f
Merge branch 'andymccurdy:master' into cluster-mode
barshaul 09a373d
Changed crc to use implementation from python stdlib binascii.
barshaul dff75fa
Merge from andymccurdy/redis-py
barshaul 19362e0
Merged branch 'andymccurdy-master' into cluster-mode
barshaul 21e6221
1. Added an optional argument of function pointer 'on_redis_connectio…
barshaul f7c5be2
Added support for 'from_url' method
barshaul b26f910
Fetch upstream and separate commands into smaller categories
barshaul 52259ca
Merge branch 'andymccurdy-master' into cluster-mode
barshaul 9af8114
Change f-string to str.format
barshaul d83e80d
fixings flake8 errors
barshaul a8aea73
1) Redis-py/master commands.py merged.
barshaul 4da4edb
1) Redis-py/master commands.py merged.
barshaul c5b7cb8
Created a docker test environment for Redis Cluster with 2 primaries …
barshaul 97ddf1c
1. Added tests for RedisCluster object.
barshaul be76bc2
Merged from upstream
barshaul eb7c576
Merge branch 'andymccurdy-master1' into cluster-mode
barshaul 450d9ff
Added support in pub-sub
barshaul 69d4a99
Migrated the cluster tests into the existing target (so 'make test' w…
barshaul 42c413a
Added ClusterPubSub tests
barshaul cc0b088
Added tests for RedisCluster and NodesManager
barshaul ccd1667
Enabled existing tests for cluster mode: multiprocessing, connection …
barshaul 72f4e99
Changes in the docker envs: Added contatiner name to each docker, cha…
barshaul 3d51bbf
Code refactoring and cleaning
barshaul b79d2d8
Merge branch 'andymccurdy:master' into cluster-mode
barshaul 8f86d12
Merge branch 'andymccurdy:master' into cluster-mode
barshaul 166501d
Fixed 'COMMAND' response value to a dictionary
barshaul a1f437e
Added CommandsParser to cache all commands info and retrieve keys fro…
barshaul 3d5df9b
Fixed CommandsParser relevant bugs
barshaul 52e1896
Fixed CommandsParser relevant bugs
barshaul 1ffc28e
Pipeline DISCARD support (#1565)
chayim 6b4adf9
Changed the CommandsParser logic: if command is flagged as moveable, …
barshaul e68d88e
Changed the CommandsParser logic: if command is flagged as moveable, …
barshaul 9725b19
Merge branch 'andymccurdy:master' into cluster-mode
barshaul d13584d
Added locks for thread safety
barshaul 40df203
Removed skip_full_coverage_check and added require_full_coverage whic…
barshaul 85fe672
Added partial documentation for Cluster Mode support in the README file
barshaul 3917bc0
Fixed a small bug
barshaul 38fe8cc
Added support for passing 'redis_connect_func' argument in RedisClust…
barshaul 16e532e
1. Files/variables with 'slave' were renamed to 'replica'
barshaul 0ba1008
Add support for multi-key and cluster management commands in cluster-…
asheryerm e6c5138
Add support for pipeline in cluster-mode
asheryerm d1604f1
Merge pull request #5 from asheryerm/cluster-mode
asheryerm 44b00bf
Code cleanup
barshaul 05cf9fc
Added & fixed tests for Cluster Commands
barshaul 0accc89
Merging upstream
barshaul aecd3d4
Merge branch 'redis-master' into cluster-mode
barshaul 1357418
Added RedisCluster documentation to the README file
barshaul c0a4aa1
Support additional cluster management commands in cluster-mode
asheryerm 9745375
Fix mget_nonatomic
asheryerm 405a688
Merge pull request #8 from asheryerm/cluster-mode
asheryerm cd502c6
Added support in passing node flags as target nodes: PRIMARIES, REPLI…
barshaul 2feb75b
Merge branch 'cluster-mode' of https://github.com/barshaul/redis-py i…
barshaul 551a475
Added skip_full_coverage_check parameter to support skipping configur…
barshaul d65f0dc
Changed the LoadBalancer to hold a primary_name to server_idx dict in…
barshaul 255728c
small fix
barshaul ee3cacc
Added support for cluster mode
barshaul b24c2c5
Changed crc to use implementation from python stdlib binascii.
barshaul 48b2065
1. Added an optional argument of function pointer 'on_redis_connectio…
barshaul 4779f1b
Added support for 'from_url' method
barshaul d83c3a0
Change f-string to str.format
barshaul 76c830b
fixings flake8 errors
barshaul 40c6124
1) Redis-py/master commands.py merged.
barshaul fb8f6d0
1) Redis-py/master commands.py merged.
barshaul 5effb9b
Created a docker test environment for Redis Cluster with 2 primaries …
barshaul 34656ae
1. Added tests for RedisCluster object.
barshaul 730b9b6
Added support in pub-sub
barshaul 4e6e91f
Migrated the cluster tests into the existing target (so 'make test' w…
barshaul bb273c3
Added ClusterPubSub tests
barshaul c85df0c
Added tests for RedisCluster and NodesManager
barshaul 0dce1e7
Enabled existing tests for cluster mode: multiprocessing, connection …
barshaul 828accd
Changes in the docker envs: Added contatiner name to each docker, cha…
barshaul 4e7002a
Code refactoring and cleaning
barshaul 424bf04
Fixed 'COMMAND' response value to a dictionary
barshaul 37aa5c0
Added CommandsParser to cache all commands info and retrieve keys fro…
barshaul 5516db7
Fixed CommandsParser relevant bugs
barshaul e9ba7cb
Pipeline DISCARD support (#1565)
chayim 057bfc6
Changed the CommandsParser logic: if command is flagged as moveable, …
barshaul 0ef9769
Added locks for thread safety
barshaul 74d0a0d
Removed skip_full_coverage_check and added require_full_coverage whic…
barshaul 3cf8bdd
Added partial documentation for Cluster Mode support in the README file
barshaul 23e6b77
Added support for passing 'redis_connect_func' argument in RedisClust…
barshaul 157e286
1. Files/variables with 'slave' were renamed to 'replica'
barshaul 5b6ba93
Add support for multi-key and cluster management commands in cluster-…
asheryerm e13892b
Add support for pipeline in cluster-mode
asheryerm 6085b3e
Code cleanup
barshaul 97e85c7
Added & fixed tests for Cluster Commands
barshaul fdcbd30
Added RedisCluster documentation to the README file
barshaul 1ee3dc9
Added support in passing node flags as target nodes: PRIMARIES, REPLI…
barshaul 1fa5bc5
Support additional cluster management commands in cluster-mode
asheryerm ffeedd7
Fix mget_nonatomic
asheryerm 867562d
Added skip_full_coverage_check parameter to support skipping configur…
barshaul d0b9d95
Changed the LoadBalancer to hold a primary_name to server_idx dict in…
barshaul 196e82b
small fix
barshaul b2d2311
Changed ports
barshaul 3f45859
Merging master branch
barshaul 59fce5b
Merging master branch
barshaul 1c2fe3a
Merge branch 'master' of https://github.com/redis/redis-py into clust…
barshaul fac26e1
Pull branch cluster mode from barshaul-redis-py
barshaul c622f1d
Removed all single dockers for Redis Cluster nodes and created a sing…
barshaul 30fde21
Small fix
barshaul 50e56d5
Merge branch 'redis:master' into cluster-mode
barshaul 5ff58d9
Added attribution for redis-py-cluster
barshaul 41bb94a
Small flake8 fix
barshaul 5372cb6
Skip pattern PUBSUB test for cluster mode
barshaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from redis import RedisCluster as Redis | ||
from redis.cluster import ClusterNode | ||
|
||
host = 'localhost' | ||
startup_nodes = [ClusterNode(host, 6378), ClusterNode(host, 6379)] | ||
|
||
# from_url examples | ||
rc_url = Redis.from_url("redis://localhost:6379/0") | ||
print(rc_url.client_list()) | ||
print(rc_url.set('foo', 'bar1')) | ||
print(rc_url.set('zzzsdfsdf', 'bar2')) | ||
print(rc_url.keyslot('bar')) | ||
print(rc_url.set('{000}', 'bar3')) | ||
print(f"get_all_nodes: {rc_url.get_all_nodes()}") | ||
print(rc_url.get('foo')) | ||
print(rc_url.keys()) | ||
# rc = Redis(host=host, port=6379) | ||
rc = Redis(startup_nodes=startup_nodes, decode_responses=True) | ||
print(rc.get('{000}')) | ||
print(rc.keys()) | ||
print(rc.cluster_save_config(rc.get_all_primaries())) | ||
print(rc.cluster_save_config(rc.get_node(host=host, port=6378))) | ||
|
||
# READONLY examples | ||
rc_readonly = Redis(startup_nodes=startup_nodes, read_from_replicas=True) | ||
for i in range(0, 4): | ||
# Assigning the read command to the slot's servers in a Round-Robin manner | ||
print(rc_readonly.get('zzz')) | ||
# set command would be directed only to the slot's primary node | ||
rc_readonly.set('bar', 'foo2') | ||
# reset READONLY flag | ||
print(rc_readonly.readwrite()) | ||
# now the get command would be directed only to the slot's primary node | ||
print(rc_readonly.get('bar')) |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM redis-py-base:latest | ||
|
||
COPY redis.conf /usr/local/etc/redis/redis.conf | ||
COPY nodes.conf /usr/local/etc/redis/nodes.conf | ||
|
||
EXPOSE 7000 | ||
barshaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
RUN chmod 666 /usr/local/etc/redis/nodes.conf | ||
barshaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
18883b616f3f42c441cdb7d1de6106852e766156 cluster_master_1:7000@17000 myself,master - 0 1630232956498 2 connected 0-8191 | ||
01eca22229cf3c652b6fca0d09ff694183e0d2e3 cluster_master_2:7001@17001 master - 0 1630232956000 1 connected 8192-16383 | ||
52611e796814b78e90ad94be9d769a9f4f668f9a cluster_slave_1:7002@17002 slave 18883b616f3f42c441cdb7d1de6106852e766156 0 1630232954000 1 connected | ||
22221e7y5814b78e90ad94k8lh969a9ff4665h7a cluster_slave_2:7003@17003 slave 01eca22229cf3c652b6fca0d09ff694183e0d2e3 0 1630232954000 1 connected |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bind cluster_master_1 127.0.0.1 | ||
port 7000 | ||
cluster-enabled yes | ||
cluster-config-file /usr/local/etc/redis/nodes.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM redis-py-base:latest | ||
|
||
COPY redis.conf /usr/local/etc/redis/redis.conf | ||
COPY nodes.conf /usr/local/etc/redis/nodes.conf | ||
|
||
EXPOSE 7001 | ||
|
||
RUN chmod 666 /usr/local/etc/redis/nodes.conf | ||
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
18883b616f3f42c441cdb7d1de6106852e766156 cluster_master_1:7000@17000 master - 0 1630232956498 2 connected 0-8191 | ||
01eca22229cf3c652b6fca0d09ff694183e0d2e3 cluster_master_2:7001@17001 myself,master - 0 1630232956000 1 connected 8192-16383 | ||
52611e796814b78e90ad94be9d769a9f4f668f9a cluster_slave_1:7002@17002 slave 18883b616f3f42c441cdb7d1de6106852e766156 0 1630232954000 1 connected | ||
22221e7y5814b78e90ad94k8lh969a9ff4665h7a cluster_slave_2:7003@17003 slave 01eca22229cf3c652b6fca0d09ff694183e0d2e3 0 1630232954000 1 connected |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bind cluster_master_2 127.0.0.1 | ||
port 7001 | ||
cluster-enabled yes | ||
cluster-config-file /usr/local/etc/redis/nodes.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM redis-py-base:latest | ||
|
||
COPY redis.conf /usr/local/etc/redis/redis.conf | ||
COPY nodes.conf /usr/local/etc/redis/nodes.conf | ||
|
||
EXPOSE 7002 | ||
|
||
RUN chmod 666 /usr/local/etc/redis/nodes.conf | ||
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
18883b616f3f42c441cdb7d1de6106852e766156 cluster_master_1:7000@17000 master - 0 1630232956498 2 connected 0-8191 | ||
01eca22229cf3c652b6fca0d09ff694183e0d2e3 cluster_master_2:7001@17001 master - 0 1630232956000 1 connected 8192-16383 | ||
52611e796814b78e90ad94be9d769a9f4f668f9a cluster_slave_1:7002@17002 myself,slave 18883b616f3f42c441cdb7d1de6106852e766156 0 1630232954000 1 connected | ||
22221e7y5814b78e90ad94k8lh969a9ff4665h7a cluster_slave_2:7003@17003 slave 01eca22229cf3c652b6fca0d09ff694183e0d2e3 0 1630232954000 1 connected |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bind cluster_slave_1 127.0.0.1 | ||
port 7002 | ||
cluster-enabled yes | ||
cluster-config-file /usr/local/etc/redis/nodes.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM redis-py-base:latest | ||
|
||
COPY redis.conf /usr/local/etc/redis/redis.conf | ||
COPY nodes.conf /usr/local/etc/redis/nodes.conf | ||
|
||
EXPOSE 7003 | ||
|
||
RUN chmod 666 /usr/local/etc/redis/nodes.conf | ||
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
18883b616f3f42c441cdb7d1de6106852e766156 cluster_master_1:7000@17000 master - 0 1630232956498 2 connected 0-8191 | ||
01eca22229cf3c652b6fca0d09ff694183e0d2e3 cluster_master_2:7001@17001 master - 0 1630232956000 1 connected 8192-16383 | ||
52611e796814b78e90ad94be9d769a9f4f668f9a cluster_slave_1:7002@17002 slave 18883b616f3f42c441cdb7d1de6106852e766156 0 1630232954000 1 connected | ||
22221e7y5814b78e90ad94k8lh969a9ff4665h7a cluster_slave_2:7003@17003 myself,slave 01eca22229cf3c652b6fca0d09ff694183e0d2e3 0 1630232954000 1 connected |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bind cluster_slave_2 127.0.0.1 | ||
port 7003 | ||
cluster-enabled yes | ||
cluster-config-file /usr/local/etc/redis/nodes.conf |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.