Skip to content

Commit 922c689

Browse files
authored
Removing support for RedisGears module. (#3553)
1 parent daf6655 commit 922c689

File tree

7 files changed

+4
-237
lines changed

7 files changed

+4
-237
lines changed

redis/cluster.py

-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ class AbstractRedisCluster:
307307
"FUNCTION LIST",
308308
"FUNCTION LOAD",
309309
"FUNCTION RESTORE",
310-
"REDISGEARS_2.REFRESHCLUSTER",
311310
"SCAN",
312311
"SCRIPT EXISTS",
313312
"SCRIPT FLUSH",

redis/commands/cluster.py

-10
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
AsyncACLCommands,
3232
AsyncDataAccessCommands,
3333
AsyncFunctionCommands,
34-
AsyncGearsCommands,
3534
AsyncManagementCommands,
3635
AsyncModuleCommands,
3736
AsyncScriptCommands,
3837
DataAccessCommands,
3938
FunctionCommands,
40-
GearsCommands,
4139
ManagementCommands,
4240
ModuleCommands,
4341
PubSubCommands,
@@ -693,12 +691,6 @@ def readwrite(self, target_nodes: Optional["TargetNodesT"] = None) -> ResponseT:
693691
self.read_from_replicas = False
694692
return self.execute_command("READWRITE", target_nodes=target_nodes)
695693

696-
def gears_refresh_cluster(self, **kwargs) -> ResponseT:
697-
"""
698-
On an OSS cluster, before executing any gears function, you must call this command. # noqa
699-
"""
700-
return self.execute_command("REDISGEARS_2.REFRESHCLUSTER", **kwargs)
701-
702694

703695
class AsyncClusterManagementCommands(
704696
ClusterManagementCommands, AsyncManagementCommands
@@ -874,7 +866,6 @@ class RedisClusterCommands(
874866
ClusterDataAccessCommands,
875867
ScriptCommands,
876868
FunctionCommands,
877-
GearsCommands,
878869
ModuleCommands,
879870
RedisModuleCommands,
880871
):
@@ -905,7 +896,6 @@ class AsyncRedisClusterCommands(
905896
AsyncClusterDataAccessCommands,
906897
AsyncScriptCommands,
907898
AsyncFunctionCommands,
908-
AsyncGearsCommands,
909899
AsyncModuleCommands,
910900
AsyncRedisModuleCommands,
911901
):

redis/commands/core.py

-127
Original file line numberDiff line numberDiff line change
@@ -6470,131 +6470,6 @@ def function_stats(self) -> Union[Awaitable[List], List]:
64706470
AsyncFunctionCommands = FunctionCommands
64716471

64726472

6473-
class GearsCommands:
6474-
def tfunction_load(
6475-
self, lib_code: str, replace: bool = False, config: Union[str, None] = None
6476-
) -> ResponseT:
6477-
"""
6478-
Load a new library to RedisGears.
6479-
6480-
``lib_code`` - the library code.
6481-
``config`` - a string representation of a JSON object
6482-
that will be provided to the library on load time,
6483-
for more information refer to
6484-
https://github.com/RedisGears/RedisGears/blob/master/docs/function_advance_topics.md#library-configuration
6485-
``replace`` - an optional argument, instructs RedisGears to replace the
6486-
function if its already exists
6487-
6488-
For more information see https://redis.io/commands/tfunction-load/
6489-
"""
6490-
pieces = []
6491-
if replace:
6492-
pieces.append("REPLACE")
6493-
if config is not None:
6494-
pieces.extend(["CONFIG", config])
6495-
pieces.append(lib_code)
6496-
return self.execute_command("TFUNCTION LOAD", *pieces)
6497-
6498-
def tfunction_delete(self, lib_name: str) -> ResponseT:
6499-
"""
6500-
Delete a library from RedisGears.
6501-
6502-
``lib_name`` the library name to delete.
6503-
6504-
For more information see https://redis.io/commands/tfunction-delete/
6505-
"""
6506-
return self.execute_command("TFUNCTION DELETE", lib_name)
6507-
6508-
def tfunction_list(
6509-
self,
6510-
with_code: bool = False,
6511-
verbose: int = 0,
6512-
lib_name: Union[str, None] = None,
6513-
) -> ResponseT:
6514-
"""
6515-
List the functions with additional information about each function.
6516-
6517-
``with_code`` Show libraries code.
6518-
``verbose`` output verbosity level, higher number will increase verbosity level
6519-
``lib_name`` specifying a library name (can be used multiple times to show multiple libraries in a single command) # noqa
6520-
6521-
For more information see https://redis.io/commands/tfunction-list/
6522-
"""
6523-
pieces = []
6524-
if with_code:
6525-
pieces.append("WITHCODE")
6526-
if verbose >= 1 and verbose <= 3:
6527-
pieces.append("v" * verbose)
6528-
else:
6529-
raise DataError("verbose can be 1, 2 or 3")
6530-
if lib_name is not None:
6531-
pieces.append("LIBRARY")
6532-
pieces.append(lib_name)
6533-
6534-
return self.execute_command("TFUNCTION LIST", *pieces)
6535-
6536-
def _tfcall(
6537-
self,
6538-
lib_name: str,
6539-
func_name: str,
6540-
keys: KeysT = None,
6541-
_async: bool = False,
6542-
*args: List,
6543-
) -> ResponseT:
6544-
pieces = [f"{lib_name}.{func_name}"]
6545-
if keys is not None:
6546-
pieces.append(len(keys))
6547-
pieces.extend(keys)
6548-
else:
6549-
pieces.append(0)
6550-
if args is not None:
6551-
pieces.extend(args)
6552-
if _async:
6553-
return self.execute_command("TFCALLASYNC", *pieces)
6554-
return self.execute_command("TFCALL", *pieces)
6555-
6556-
def tfcall(
6557-
self,
6558-
lib_name: str,
6559-
func_name: str,
6560-
keys: KeysT = None,
6561-
*args: List,
6562-
) -> ResponseT:
6563-
"""
6564-
Invoke a function.
6565-
6566-
``lib_name`` - the library name contains the function.
6567-
``func_name`` - the function name to run.
6568-
``keys`` - the keys that will be touched by the function.
6569-
``args`` - Additional argument to pass to the function.
6570-
6571-
For more information see https://redis.io/commands/tfcall/
6572-
"""
6573-
return self._tfcall(lib_name, func_name, keys, False, *args)
6574-
6575-
def tfcall_async(
6576-
self,
6577-
lib_name: str,
6578-
func_name: str,
6579-
keys: KeysT = None,
6580-
*args: List,
6581-
) -> ResponseT:
6582-
"""
6583-
Invoke an async function (coroutine).
6584-
6585-
``lib_name`` - the library name contains the function.
6586-
``func_name`` - the function name to run.
6587-
``keys`` - the keys that will be touched by the function.
6588-
``args`` - Additional argument to pass to the function.
6589-
6590-
For more information see https://redis.io/commands/tfcall/
6591-
"""
6592-
return self._tfcall(lib_name, func_name, keys, True, *args)
6593-
6594-
6595-
AsyncGearsCommands = GearsCommands
6596-
6597-
65986473
class DataAccessCommands(
65996474
BasicKeyCommands,
66006475
HyperlogCommands,
@@ -6638,7 +6513,6 @@ class CoreCommands(
66386513
PubSubCommands,
66396514
ScriptCommands,
66406515
FunctionCommands,
6641-
GearsCommands,
66426516
):
66436517
"""
66446518
A class containing all of the implemented redis commands. This class is
@@ -6655,7 +6529,6 @@ class AsyncCoreCommands(
66556529
AsyncPubSubCommands,
66566530
AsyncScriptCommands,
66576531
AsyncFunctionCommands,
6658-
AsyncGearsCommands,
66596532
):
66606533
"""
66616534
A class containing all of the implemented redis commands. This class is

tests/test_cluster.py

-44
Original file line numberDiff line numberDiff line change
@@ -2448,50 +2448,6 @@ def try_delete_libs(self, r, *lib_names):
24482448
except Exception:
24492449
pass
24502450

2451-
@pytest.mark.redismod
2452-
@skip_if_server_version_lt("7.1.140")
2453-
def test_tfunction_load_delete(self, r):
2454-
r.gears_refresh_cluster()
2455-
self.try_delete_libs(r, "lib1")
2456-
lib_code = self.generate_lib_code("lib1")
2457-
assert r.tfunction_load(lib_code)
2458-
assert r.tfunction_delete("lib1")
2459-
2460-
@pytest.mark.redismod
2461-
@skip_if_server_version_lt("7.1.140")
2462-
def test_tfunction_list(self, r):
2463-
r.gears_refresh_cluster()
2464-
self.try_delete_libs(r, "lib1", "lib2", "lib3")
2465-
assert r.tfunction_load(self.generate_lib_code("lib1"))
2466-
assert r.tfunction_load(self.generate_lib_code("lib2"))
2467-
assert r.tfunction_load(self.generate_lib_code("lib3"))
2468-
2469-
# test error thrown when verbose > 4
2470-
with pytest.raises(DataError):
2471-
assert r.tfunction_list(verbose=8)
2472-
2473-
functions = r.tfunction_list(verbose=1)
2474-
assert len(functions) == 3
2475-
2476-
expected_names = [b"lib1", b"lib2", b"lib3"]
2477-
actual_names = [functions[0][13], functions[1][13], functions[2][13]]
2478-
2479-
assert sorted(expected_names) == sorted(actual_names)
2480-
assert r.tfunction_delete("lib1")
2481-
assert r.tfunction_delete("lib2")
2482-
assert r.tfunction_delete("lib3")
2483-
2484-
@pytest.mark.redismod
2485-
@skip_if_server_version_lt("7.1.140")
2486-
def test_tfcall(self, r):
2487-
r.gears_refresh_cluster()
2488-
self.try_delete_libs(r, "lib1")
2489-
assert r.tfunction_load(self.generate_lib_code("lib1"))
2490-
assert r.tfcall("lib1", "foo") == b"bar"
2491-
assert r.tfcall_async("lib1", "foo") == b"bar"
2492-
2493-
assert r.tfunction_delete("lib1")
2494-
24952451

24962452
@pytest.mark.onlycluster
24972453
class TestNodesManager:

tests/test_commands.py

-51
Original file line numberDiff line numberDiff line change
@@ -2050,57 +2050,6 @@ def try_delete_libs(self, r, *lib_names):
20502050
except Exception:
20512051
pass
20522052

2053-
@pytest.mark.onlynoncluster
2054-
@skip_if_server_version_lt("7.1.140")
2055-
@skip_if_server_version_gte("7.9.0")
2056-
def test_tfunction_load_delete(self, stack_r):
2057-
self.try_delete_libs(stack_r, "lib1")
2058-
lib_code = self.generate_lib_code("lib1")
2059-
assert stack_r.tfunction_load(lib_code)
2060-
assert stack_r.tfunction_delete("lib1")
2061-
2062-
@pytest.mark.onlynoncluster
2063-
@skip_if_server_version_lt("7.1.140")
2064-
@skip_if_server_version_gte("7.9.0")
2065-
def test_tfunction_list(self, stack_r):
2066-
self.try_delete_libs(stack_r, "lib1", "lib2", "lib3")
2067-
assert stack_r.tfunction_load(self.generate_lib_code("lib1"))
2068-
assert stack_r.tfunction_load(self.generate_lib_code("lib2"))
2069-
assert stack_r.tfunction_load(self.generate_lib_code("lib3"))
2070-
2071-
# test error thrown when verbose > 4
2072-
with pytest.raises(redis.exceptions.DataError):
2073-
assert stack_r.tfunction_list(verbose=8)
2074-
2075-
functions = stack_r.tfunction_list(verbose=1)
2076-
assert len(functions) == 3
2077-
2078-
expected_names = [b"lib1", b"lib2", b"lib3"]
2079-
if is_resp2_connection(stack_r):
2080-
actual_names = [functions[0][13], functions[1][13], functions[2][13]]
2081-
else:
2082-
actual_names = [
2083-
functions[0][b"name"],
2084-
functions[1][b"name"],
2085-
functions[2][b"name"],
2086-
]
2087-
2088-
assert sorted(expected_names) == sorted(actual_names)
2089-
assert stack_r.tfunction_delete("lib1")
2090-
assert stack_r.tfunction_delete("lib2")
2091-
assert stack_r.tfunction_delete("lib3")
2092-
2093-
@pytest.mark.onlynoncluster
2094-
@skip_if_server_version_lt("7.1.140")
2095-
@skip_if_server_version_gte("7.9.0")
2096-
def test_tfcall(self, stack_r):
2097-
self.try_delete_libs(stack_r, "lib1")
2098-
assert stack_r.tfunction_load(self.generate_lib_code("lib1"))
2099-
assert stack_r.tfcall("lib1", "foo") == b"bar"
2100-
assert stack_r.tfcall_async("lib1", "foo") == b"bar"
2101-
2102-
assert stack_r.tfunction_delete("lib1")
2103-
21042053
def test_ttl(self, r):
21052054
r["a"] = "1"
21062055
assert r.expire("a", 10)

tests/test_connection_pool.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def test_reuse_previously_released_connection(self, master_host):
9494
def test_release_not_owned_connection(self, master_host):
9595
connection_kwargs = {"host": master_host[0], "port": master_host[1]}
9696
pool1 = self.get_pool(connection_kwargs=connection_kwargs)
97-
c1 = pool1.get_connection("_")
97+
c1 = pool1.get_connection()
9898
pool2 = self.get_pool(
9999
connection_kwargs={"host": master_host[0], "port": master_host[1]}
100100
)
101-
c2 = pool2.get_connection("_")
101+
c2 = pool2.get_connection()
102102
pool2.release(c2)
103103

104104
assert len(pool2._available_connections) == 1

tests/test_multiprocessing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ def test_release_parent_connection_from_pool_in_child_process(
105105
max_connections=max_connections,
106106
)
107107

108-
parent_conn = pool.get_connection("ping")
108+
parent_conn = pool.get_connection()
109109

110110
def target(pool, parent_conn):
111111
with exit_callback(pool.disconnect):
112-
child_conn = pool.get_connection("ping")
112+
child_conn = pool.get_connection()
113113
assert child_conn.pid != parent_conn.pid
114114
pool.release(child_conn)
115115
assert pool._created_connections == 1

0 commit comments

Comments
 (0)