valkey-glide 1.3.5__cp39-cp39-macosx_11_0_arm64.whl → 2.2.2__cp39-cp39-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- glide/__init__.py +165 -107
- glide/async_commands/cluster_commands.py +318 -136
- glide/async_commands/core.py +1770 -992
- glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
- glide/async_commands/{server_modules/glide_json.py → glide_json.py} +148 -134
- glide/async_commands/standalone_commands.py +203 -137
- glide/glide.cpython-39-darwin.so +0 -0
- glide/glide.pyi +26 -1
- glide/glide_client.py +352 -135
- glide/logger.py +34 -22
- glide/opentelemetry.py +185 -0
- glide_shared/__init__.py +330 -0
- glide_shared/commands/__init__.py +0 -0
- glide/async_commands/transaction.py → glide_shared/commands/batch.py +1839 -1017
- glide_shared/commands/batch_options.py +261 -0
- {glide/async_commands → glide_shared/commands}/bitmap.py +94 -85
- {glide/async_commands → glide_shared/commands}/command_args.py +7 -6
- glide_shared/commands/core_options.py +407 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +18 -11
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +27 -13
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +16 -11
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +16 -8
- {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +160 -130
- glide_shared/commands/server_modules/json_options.py +93 -0
- {glide/async_commands → glide_shared/commands}/sorted_set.py +41 -31
- {glide/async_commands → glide_shared/commands}/stream.py +95 -88
- glide_shared/config.py +975 -0
- {glide → glide_shared}/constants.py +11 -7
- {glide → glide_shared}/exceptions.py +27 -1
- glide_shared/protobuf/command_request_pb2.py +56 -0
- glide_shared/protobuf/connection_request_pb2.py +56 -0
- {glide → glide_shared}/protobuf/response_pb2.py +6 -6
- {glide → glide_shared}/protobuf_codec.py +7 -6
- glide_shared/routes.py +161 -0
- valkey_glide-2.2.2.dist-info/METADATA +211 -0
- valkey_glide-2.2.2.dist-info/RECORD +40 -0
- glide/config.py +0 -590
- glide/protobuf/command_request_pb2.py +0 -54
- glide/protobuf/command_request_pb2.pyi +0 -1164
- glide/protobuf/connection_request_pb2.py +0 -52
- glide/protobuf/connection_request_pb2.pyi +0 -292
- glide/protobuf/response_pb2.pyi +0 -101
- glide/routes.py +0 -114
- valkey_glide-1.3.5.dist-info/METADATA +0 -125
- valkey_glide-1.3.5.dist-info/RECORD +0 -37
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
- {valkey_glide-1.3.5.dist-info → valkey_glide-2.2.2.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from glide_shared.constants import TEncodable
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class JsonArrIndexOptions:
|
|
9
|
+
"""
|
|
10
|
+
Options for the `JSON.ARRINDEX` command.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
start (int): The inclusive start index from which the search begins. Defaults to None.
|
|
14
|
+
end (Optional[int]): The exclusive end index where the search stops. Defaults to None.
|
|
15
|
+
|
|
16
|
+
Note:
|
|
17
|
+
- If `start` is greater than `end`, the command returns `-1` to indicate that the value was not found.
|
|
18
|
+
- Indices that exceed the array bounds are automatically adjusted to the nearest valid position.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, start: int, end: Optional[int] = None):
|
|
22
|
+
self.start = start
|
|
23
|
+
self.end = end
|
|
24
|
+
|
|
25
|
+
def to_args(self) -> List[str]:
|
|
26
|
+
"""
|
|
27
|
+
Get the options as a list of arguments for the JSON.ARRINDEX command.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
List[str]: A list containing the start and end indices if specified.
|
|
31
|
+
"""
|
|
32
|
+
args = [str(self.start)]
|
|
33
|
+
if self.end is not None:
|
|
34
|
+
args.append(str(self.end))
|
|
35
|
+
return args
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class JsonArrPopOptions:
|
|
39
|
+
"""
|
|
40
|
+
Options for the JSON.ARRPOP command.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
path (TEncodable): The path within the JSON document.
|
|
44
|
+
index (Optional[int]): The index of the element to pop. If not specified, will pop the last element.
|
|
45
|
+
Out of boundary indexes are rounded to their respective array boundaries. Defaults to None.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self, path: TEncodable, index: Optional[int] = None):
|
|
49
|
+
self.path = path
|
|
50
|
+
self.index = index
|
|
51
|
+
|
|
52
|
+
def to_args(self) -> List[TEncodable]:
|
|
53
|
+
"""
|
|
54
|
+
Get the options as a list of arguments for the `JSON.ARRPOP` command.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
List[TEncodable]: A list containing the path and, if specified, the index.
|
|
58
|
+
"""
|
|
59
|
+
args = [self.path]
|
|
60
|
+
if self.index is not None:
|
|
61
|
+
args.append(str(self.index))
|
|
62
|
+
return args
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class JsonGetOptions:
|
|
66
|
+
"""
|
|
67
|
+
Represents options for formatting JSON data, to be used in the [JSON.GET](https://valkey.io/commands/json.get/) command.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
indent (Optional[str]): Sets an indentation string for nested levels. Defaults to None.
|
|
71
|
+
newline (Optional[str]): Sets a string that's printed at the end of each line. Defaults to None.
|
|
72
|
+
space (Optional[str]): Sets a string that's put between a key and a value. Defaults to None.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def __init__(
|
|
76
|
+
self,
|
|
77
|
+
indent: Optional[str] = None,
|
|
78
|
+
newline: Optional[str] = None,
|
|
79
|
+
space: Optional[str] = None,
|
|
80
|
+
):
|
|
81
|
+
self.indent = indent
|
|
82
|
+
self.new_line = newline
|
|
83
|
+
self.space = space
|
|
84
|
+
|
|
85
|
+
def get_options(self) -> List[str]:
|
|
86
|
+
args = []
|
|
87
|
+
if self.indent:
|
|
88
|
+
args.extend(["INDENT", self.indent])
|
|
89
|
+
if self.new_line:
|
|
90
|
+
args.extend(["NEWLINE", self.new_line])
|
|
91
|
+
if self.space:
|
|
92
|
+
args.extend(["SPACE", self.space])
|
|
93
|
+
return args
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import List, Optional, Tuple, Union, cast
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
6
|
+
from glide_shared.commands.command_args import Limit, OrderBy
|
|
7
|
+
from glide_shared.constants import TEncodable
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class InfBound(Enum):
|
|
@@ -15,14 +15,18 @@ class InfBound(Enum):
|
|
|
15
15
|
POS_INF = {"score_arg": "+inf", "lex_arg": "+"}
|
|
16
16
|
"""
|
|
17
17
|
Positive infinity bound for sorted set.
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
`score_arg`: represents numeric positive infinity (+inf).
|
|
20
|
+
|
|
21
|
+
`lex_arg`: represents lexicographic positive infinity (+).
|
|
20
22
|
"""
|
|
21
23
|
NEG_INF = {"score_arg": "-inf", "lex_arg": "-"}
|
|
22
24
|
"""
|
|
23
25
|
Negative infinity bound for sorted set.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
`score_arg`: represents numeric negative infinity (-inf).
|
|
28
|
+
|
|
29
|
+
`lex_arg`: represents lexicographic negative infinity (-).
|
|
26
30
|
"""
|
|
27
31
|
|
|
28
32
|
|
|
@@ -49,8 +53,8 @@ class ScoreFilter(Enum):
|
|
|
49
53
|
"""
|
|
50
54
|
Defines which elements to pop from a sorted set.
|
|
51
55
|
|
|
52
|
-
ScoreFilter is a mandatory option for ZMPOP
|
|
53
|
-
and BZMPOP
|
|
56
|
+
ScoreFilter is a mandatory option for [ZMPOP](https://valkey.io/commands/zmpop)
|
|
57
|
+
and [BZMPOP](https://valkey.io/commands/bzmpop).
|
|
54
58
|
"""
|
|
55
59
|
|
|
56
60
|
MIN = "MIN"
|
|
@@ -97,7 +101,7 @@ class RangeByIndex:
|
|
|
97
101
|
|
|
98
102
|
The `start` and `end` arguments represent zero-based indexes.
|
|
99
103
|
|
|
100
|
-
|
|
104
|
+
Attributes:
|
|
101
105
|
start (int): The start index of the range.
|
|
102
106
|
end (int): The end index of the range.
|
|
103
107
|
"""
|
|
@@ -113,10 +117,11 @@ class RangeByScore:
|
|
|
113
117
|
|
|
114
118
|
The `start` and `end` arguments represent score boundaries.
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
Attributes:
|
|
117
121
|
start (Union[InfBound, ScoreBoundary]): The start score boundary.
|
|
118
122
|
end (Union[InfBound, ScoreBoundary]): The end score boundary.
|
|
119
|
-
limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit`
|
|
123
|
+
limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit`
|
|
124
|
+
class for more information.
|
|
120
125
|
"""
|
|
121
126
|
|
|
122
127
|
def __init__(
|
|
@@ -126,9 +131,9 @@ class RangeByScore:
|
|
|
126
131
|
limit: Optional[Limit] = None,
|
|
127
132
|
):
|
|
128
133
|
self.start = (
|
|
129
|
-
start.value["score_arg"] if
|
|
134
|
+
start.value["score_arg"] if isinstance(start, InfBound) else start.value
|
|
130
135
|
)
|
|
131
|
-
self.end = end.value["score_arg"] if
|
|
136
|
+
self.end = end.value["score_arg"] if isinstance(end, InfBound) else end.value
|
|
132
137
|
self.limit = limit
|
|
133
138
|
|
|
134
139
|
|
|
@@ -138,10 +143,11 @@ class RangeByLex:
|
|
|
138
143
|
|
|
139
144
|
The `start` and `end` arguments represent lexicographical boundaries.
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
Attributes:
|
|
142
147
|
start (Union[InfBound, LexBoundary]): The start lexicographic boundary.
|
|
143
148
|
end (Union[InfBound, LexBoundary]): The end lexicographic boundary.
|
|
144
|
-
limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit` class
|
|
149
|
+
limit (Optional[Limit]): The limit argument for a range query. Defaults to None. See `Limit` class
|
|
150
|
+
for more information.
|
|
145
151
|
"""
|
|
146
152
|
|
|
147
153
|
def __init__(
|
|
@@ -150,24 +156,28 @@ class RangeByLex:
|
|
|
150
156
|
end: Union[InfBound, LexBoundary],
|
|
151
157
|
limit: Optional[Limit] = None,
|
|
152
158
|
):
|
|
153
|
-
self.start =
|
|
154
|
-
|
|
159
|
+
self.start = (
|
|
160
|
+
start.value["lex_arg"] if isinstance(start, InfBound) else start.value
|
|
161
|
+
)
|
|
162
|
+
self.end = end.value["lex_arg"] if isinstance(end, InfBound) else end.value
|
|
155
163
|
self.limit = limit
|
|
156
164
|
|
|
157
165
|
|
|
158
166
|
class GeospatialData:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Represents a geographic position defined by longitude and latitude.
|
|
167
|
+
"""
|
|
168
|
+
Represents a geographic position defined by longitude and latitude.
|
|
162
169
|
|
|
163
|
-
|
|
164
|
-
- Valid longitudes are from -180 to 180 degrees.
|
|
165
|
-
- Valid latitudes are from -85.05112878 to 85.05112878 degrees.
|
|
170
|
+
The exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following:
|
|
166
171
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
- Valid longitudes are from -180 to 180 degrees.
|
|
173
|
+
- Valid latitudes are from -85.05112878 to 85.05112878 degrees.
|
|
174
|
+
|
|
175
|
+
Attributes:
|
|
176
|
+
longitude (float): The longitude coordinate.
|
|
177
|
+
latitude (float): The latitude coordinate.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
def __init__(self, longitude: float, latitude: float):
|
|
171
181
|
self.longitude = longitude
|
|
172
182
|
self.latitude = latitude
|
|
173
183
|
|
|
@@ -199,7 +209,7 @@ class GeoSearchByRadius:
|
|
|
199
209
|
"""
|
|
200
210
|
Represents search criteria of searching within a certain radius from a specified point.
|
|
201
211
|
|
|
202
|
-
|
|
212
|
+
Attributes:
|
|
203
213
|
radius (float): Radius of the search area.
|
|
204
214
|
unit (GeoUnit): Unit of the radius. See `GeoUnit`.
|
|
205
215
|
"""
|
|
@@ -225,7 +235,7 @@ class GeoSearchByBox:
|
|
|
225
235
|
"""
|
|
226
236
|
Represents search criteria of searching within a specified rectangular area.
|
|
227
237
|
|
|
228
|
-
|
|
238
|
+
Attributes:
|
|
229
239
|
width (float): Width of the bounding box.
|
|
230
240
|
height (float): Height of the bounding box
|
|
231
241
|
unit (GeoUnit): Unit of the radius. See `GeoUnit`.
|
|
@@ -253,10 +263,10 @@ class GeoSearchCount:
|
|
|
253
263
|
"""
|
|
254
264
|
Represents the count option for limiting the number of results in a GeoSearch.
|
|
255
265
|
|
|
256
|
-
|
|
266
|
+
Attributes:
|
|
257
267
|
count (int): The maximum number of results to return.
|
|
258
268
|
any_option (bool): Whether to allow returning as enough matches are found.
|
|
259
|
-
|
|
269
|
+
This means that the results returned may not be the ones closest to the specified point. Default to False.
|
|
260
270
|
"""
|
|
261
271
|
|
|
262
272
|
def __init__(self, count: int, any_option: bool = False):
|
|
@@ -4,12 +4,20 @@ from __future__ import annotations
|
|
|
4
4
|
from abc import ABC, abstractmethod
|
|
5
5
|
from typing import List, Optional, Union
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from glide_shared.constants import TEncodable
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class StreamTrimOptions(ABC):
|
|
11
11
|
"""
|
|
12
12
|
Abstract base class for stream trim options.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
16
|
+
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
17
|
+
threshold (Union[TEncodable, int]): Threshold for trimming.
|
|
18
|
+
method (str): Method for trimming (e.g., MINID, MAXLEN).
|
|
19
|
+
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
20
|
+
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
13
21
|
"""
|
|
14
22
|
|
|
15
23
|
@abstractmethod
|
|
@@ -22,14 +30,6 @@ class StreamTrimOptions(ABC):
|
|
|
22
30
|
):
|
|
23
31
|
"""
|
|
24
32
|
Initialize stream trim options.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
28
|
-
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
29
|
-
threshold (Union[TEncodable, int]): Threshold for trimming.
|
|
30
|
-
method (str): Method for trimming (e.g., MINID, MAXLEN).
|
|
31
|
-
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
32
|
-
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
33
33
|
"""
|
|
34
34
|
if exact and limit:
|
|
35
35
|
raise ValueError(
|
|
@@ -60,18 +60,18 @@ class StreamTrimOptions(ABC):
|
|
|
60
60
|
class TrimByMinId(StreamTrimOptions):
|
|
61
61
|
"""
|
|
62
62
|
Stream trim option to trim by minimum ID.
|
|
63
|
+
|
|
64
|
+
Attributes:
|
|
65
|
+
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
66
|
+
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
67
|
+
threshold (TEncodable): Threshold for trimming by minimum ID.
|
|
68
|
+
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
69
|
+
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
63
70
|
"""
|
|
64
71
|
|
|
65
72
|
def __init__(self, exact: bool, threshold: TEncodable, limit: Optional[int] = None):
|
|
66
73
|
"""
|
|
67
74
|
Initialize trim option by minimum ID.
|
|
68
|
-
|
|
69
|
-
Args:
|
|
70
|
-
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
71
|
-
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
72
|
-
threshold (TEncodable): Threshold for trimming by minimum ID.
|
|
73
|
-
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
74
|
-
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
75
75
|
"""
|
|
76
76
|
super().__init__(exact, threshold, "MINID", limit)
|
|
77
77
|
|
|
@@ -79,18 +79,18 @@ class TrimByMinId(StreamTrimOptions):
|
|
|
79
79
|
class TrimByMaxLen(StreamTrimOptions):
|
|
80
80
|
"""
|
|
81
81
|
Stream trim option to trim by maximum length.
|
|
82
|
+
|
|
83
|
+
Attributes:
|
|
84
|
+
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
85
|
+
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
86
|
+
threshold (int): Threshold for trimming by maximum length.
|
|
87
|
+
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
88
|
+
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
82
89
|
"""
|
|
83
90
|
|
|
84
91
|
def __init__(self, exact: bool, threshold: int, limit: Optional[int] = None):
|
|
85
92
|
"""
|
|
86
93
|
Initialize trim option by maximum length.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
exact (bool): If `true`, the stream will be trimmed exactly.
|
|
90
|
-
Otherwise the stream will be trimmed in a near-exact manner, which is more efficient.
|
|
91
|
-
threshold (int): Threshold for trimming by maximum length.
|
|
92
|
-
limit (Optional[int]): Max number of entries to be trimmed. Defaults to None.
|
|
93
|
-
Note: If `exact` is set to `True`, `limit` cannot be specified.
|
|
94
94
|
"""
|
|
95
95
|
super().__init__(exact, threshold, "MAXLEN", limit)
|
|
96
96
|
|
|
@@ -98,6 +98,13 @@ class TrimByMaxLen(StreamTrimOptions):
|
|
|
98
98
|
class StreamAddOptions:
|
|
99
99
|
"""
|
|
100
100
|
Options for adding entries to a stream.
|
|
101
|
+
|
|
102
|
+
Attributes:
|
|
103
|
+
id (Optional[TEncodable]): ID for the new entry. If set, the new entry will be added with this ID. If not
|
|
104
|
+
specified, '*' is used.
|
|
105
|
+
make_stream (bool, optional): If set to False, a new stream won't be created if no stream matches the given key.
|
|
106
|
+
trim (Optional[StreamTrimOptions]): If set, the add operation will also trim the older entries in the stream.
|
|
107
|
+
See `StreamTrimOptions`.
|
|
101
108
|
"""
|
|
102
109
|
|
|
103
110
|
def __init__(
|
|
@@ -108,11 +115,6 @@ class StreamAddOptions:
|
|
|
108
115
|
):
|
|
109
116
|
"""
|
|
110
117
|
Initialize stream add options.
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
id (Optional[TEncodable]): ID for the new entry. If set, the new entry will be added with this ID. If not specified, '*' is used.
|
|
114
|
-
make_stream (bool, optional): If set to False, a new stream won't be created if no stream matches the given key.
|
|
115
|
-
trim (Optional[StreamTrimOptions]): If set, the add operation will also trim the older entries in the stream. See `StreamTrimOptions`.
|
|
116
118
|
"""
|
|
117
119
|
self.id = id
|
|
118
120
|
self.make_stream = make_stream
|
|
@@ -178,6 +180,9 @@ class IdBound(StreamRangeBound):
|
|
|
178
180
|
Inclusive (closed) stream ID boundary used to specify a range of IDs to search. Stream ID bounds can be complete
|
|
179
181
|
with a timestamp and sequence number separated by a dash ("-"), for example "1526985054069-0". Stream ID bounds can
|
|
180
182
|
also be incomplete, with just a timestamp.
|
|
183
|
+
|
|
184
|
+
Attributes:
|
|
185
|
+
stream_id (str): The stream ID.
|
|
181
186
|
"""
|
|
182
187
|
|
|
183
188
|
@staticmethod
|
|
@@ -193,9 +198,6 @@ class IdBound(StreamRangeBound):
|
|
|
193
198
|
def __init__(self, stream_id: TEncodable):
|
|
194
199
|
"""
|
|
195
200
|
Creates a stream ID boundary for a range search.
|
|
196
|
-
|
|
197
|
-
Args:
|
|
198
|
-
stream_id (str): The stream ID.
|
|
199
201
|
"""
|
|
200
202
|
self.stream_id = stream_id
|
|
201
203
|
|
|
@@ -210,6 +212,9 @@ class ExclusiveIdBound(StreamRangeBound):
|
|
|
210
212
|
be incomplete, with just a timestamp.
|
|
211
213
|
|
|
212
214
|
Since: Valkey version 6.2.0.
|
|
215
|
+
|
|
216
|
+
Attributes:
|
|
217
|
+
stream_id (TEncodable): The stream ID.
|
|
213
218
|
"""
|
|
214
219
|
|
|
215
220
|
EXCLUSIVE_BOUND_VALKEY_API = "("
|
|
@@ -227,9 +232,6 @@ class ExclusiveIdBound(StreamRangeBound):
|
|
|
227
232
|
def __init__(self, stream_id: TEncodable):
|
|
228
233
|
"""
|
|
229
234
|
Creates a stream ID boundary for a range search.
|
|
230
|
-
|
|
231
|
-
Args:
|
|
232
|
-
stream_id (TEncodable): The stream ID.
|
|
233
235
|
"""
|
|
234
236
|
if isinstance(stream_id, bytes):
|
|
235
237
|
stream_id = stream_id.decode("utf-8")
|
|
@@ -240,18 +242,19 @@ class ExclusiveIdBound(StreamRangeBound):
|
|
|
240
242
|
|
|
241
243
|
|
|
242
244
|
class StreamReadOptions:
|
|
245
|
+
"""
|
|
246
|
+
Options for reading entries from streams. Can be used as an optional argument to `XREAD`.
|
|
247
|
+
|
|
248
|
+
Attributes:
|
|
249
|
+
block_ms (Optional[int]): If provided, the request will be blocked for the set amount of milliseconds or
|
|
250
|
+
until the server has the required number of entries. Equivalent to `BLOCK` in the Valkey API.
|
|
251
|
+
count (Optional[int]): The maximum number of elements requested. Equivalent to `COUNT` in the Valkey API.
|
|
252
|
+
"""
|
|
253
|
+
|
|
243
254
|
READ_COUNT_VALKEY_API = "COUNT"
|
|
244
255
|
READ_BLOCK_VALKEY_API = "BLOCK"
|
|
245
256
|
|
|
246
257
|
def __init__(self, block_ms: Optional[int] = None, count: Optional[int] = None):
|
|
247
|
-
"""
|
|
248
|
-
Options for reading entries from streams. Can be used as an optional argument to `XREAD`.
|
|
249
|
-
|
|
250
|
-
Args:
|
|
251
|
-
block_ms (Optional[int]): If provided, the request will be blocked for the set amount of milliseconds or
|
|
252
|
-
until the server has the required number of entries. Equivalent to `BLOCK` in the Valkey API.
|
|
253
|
-
count (Optional[int]): The maximum number of elements requested. Equivalent to `COUNT` in the Valkey API.
|
|
254
|
-
"""
|
|
255
258
|
self.block_ms = block_ms
|
|
256
259
|
self.count = count
|
|
257
260
|
|
|
@@ -273,19 +276,20 @@ class StreamReadOptions:
|
|
|
273
276
|
|
|
274
277
|
|
|
275
278
|
class StreamGroupOptions:
|
|
279
|
+
"""
|
|
280
|
+
Options for creating stream consumer groups. Can be used as an optional argument to `XGROUP CREATE`.
|
|
281
|
+
|
|
282
|
+
Attributes:
|
|
283
|
+
make_stream (bool): If set to True and the stream doesn't exist, this creates a new stream with a
|
|
284
|
+
length of 0.
|
|
285
|
+
entries_read: (Optional[int]): A value representing the number of stream entries already read by the
|
|
286
|
+
group. This option can only be specified if you are using Valkey version 7.0.0 or above.
|
|
287
|
+
"""
|
|
288
|
+
|
|
276
289
|
MAKE_STREAM_VALKEY_API = "MKSTREAM"
|
|
277
290
|
ENTRIES_READ_VALKEY_API = "ENTRIESREAD"
|
|
278
291
|
|
|
279
292
|
def __init__(self, make_stream: bool = False, entries_read: Optional[int] = None):
|
|
280
|
-
"""
|
|
281
|
-
Options for creating stream consumer groups. Can be used as an optional argument to `XGROUP CREATE`.
|
|
282
|
-
|
|
283
|
-
Args:
|
|
284
|
-
make_stream (bool): If set to True and the stream doesn't exist, this creates a new stream with a
|
|
285
|
-
length of 0.
|
|
286
|
-
entries_read: (Optional[int]): A value representing the number of stream entries already read by the
|
|
287
|
-
group. This option can only be specified if you are using Valkey version 7.0.0 or above.
|
|
288
|
-
"""
|
|
289
293
|
self.make_stream = make_stream
|
|
290
294
|
self.entries_read = entries_read
|
|
291
295
|
|
|
@@ -307,22 +311,23 @@ class StreamGroupOptions:
|
|
|
307
311
|
|
|
308
312
|
|
|
309
313
|
class StreamReadGroupOptions(StreamReadOptions):
|
|
314
|
+
"""
|
|
315
|
+
Options for reading entries from streams using a consumer group. Can be used as an optional argument to
|
|
316
|
+
`XREADGROUP`.
|
|
317
|
+
|
|
318
|
+
Attributes:
|
|
319
|
+
no_ack (bool): If set, messages are not added to the Pending Entries List (PEL). This is equivalent to
|
|
320
|
+
acknowledging the message when it is read. Equivalent to `NOACK` in the Valkey API.
|
|
321
|
+
block_ms (Optional[int]): If provided, the request will be blocked for the set amount of milliseconds or
|
|
322
|
+
until the server has the required number of entries. Equivalent to `BLOCK` in the Valkey API.
|
|
323
|
+
count (Optional[int]): The maximum number of elements requested. Equivalent to `COUNT` in the Valkey API.
|
|
324
|
+
"""
|
|
325
|
+
|
|
310
326
|
READ_NOACK_VALKEY_API = "NOACK"
|
|
311
327
|
|
|
312
328
|
def __init__(
|
|
313
329
|
self, no_ack=False, block_ms: Optional[int] = None, count: Optional[int] = None
|
|
314
330
|
):
|
|
315
|
-
"""
|
|
316
|
-
Options for reading entries from streams using a consumer group. Can be used as an optional argument to
|
|
317
|
-
`XREADGROUP`.
|
|
318
|
-
|
|
319
|
-
Args:
|
|
320
|
-
no_ack (bool): If set, messages are not added to the Pending Entries List (PEL). This is equivalent to
|
|
321
|
-
acknowledging the message when it is read. Equivalent to `NOACK` in the Valkey API.
|
|
322
|
-
block_ms (Optional[int]): If provided, the request will be blocked for the set amount of milliseconds or
|
|
323
|
-
until the server has the required number of entries. Equivalent to `BLOCK` in the Valkey API.
|
|
324
|
-
count (Optional[int]): The maximum number of elements requested. Equivalent to `COUNT` in the Valkey API.
|
|
325
|
-
"""
|
|
326
331
|
super().__init__(block_ms=block_ms, count=count)
|
|
327
332
|
self.no_ack = no_ack
|
|
328
333
|
|
|
@@ -341,6 +346,15 @@ class StreamReadGroupOptions(StreamReadOptions):
|
|
|
341
346
|
|
|
342
347
|
|
|
343
348
|
class StreamPendingOptions:
|
|
349
|
+
"""
|
|
350
|
+
Options for `XPENDING` that can be used to filter returned items by minimum idle time and consumer name.
|
|
351
|
+
|
|
352
|
+
Attributes:
|
|
353
|
+
min_idle_time_ms (Optional[int]): Filters pending entries by their minimum idle time in milliseconds. This
|
|
354
|
+
option can only be specified if you are using Valkey version 6.2.0 or above.
|
|
355
|
+
consumer_name (Optional[TEncodable]): Filters pending entries by consumer name.
|
|
356
|
+
"""
|
|
357
|
+
|
|
344
358
|
IDLE_TIME_VALKEY_API = "IDLE"
|
|
345
359
|
|
|
346
360
|
def __init__(
|
|
@@ -348,19 +362,30 @@ class StreamPendingOptions:
|
|
|
348
362
|
min_idle_time_ms: Optional[int] = None,
|
|
349
363
|
consumer_name: Optional[TEncodable] = None,
|
|
350
364
|
):
|
|
351
|
-
"""
|
|
352
|
-
Options for `XPENDING` that can be used to filter returned items by minimum idle time and consumer name.
|
|
353
|
-
|
|
354
|
-
Args:
|
|
355
|
-
min_idle_time_ms (Optional[int]): Filters pending entries by their minimum idle time in milliseconds. This
|
|
356
|
-
option can only be specified if you are using Valkey version 6.2.0 or above.
|
|
357
|
-
consumer_name (Optional[TEncodable]): Filters pending entries by consumer name.
|
|
358
|
-
"""
|
|
359
365
|
self.min_idle_time = min_idle_time_ms
|
|
360
366
|
self.consumer_name = consumer_name
|
|
361
367
|
|
|
362
368
|
|
|
363
369
|
class StreamClaimOptions:
|
|
370
|
+
"""
|
|
371
|
+
Options for `XCLAIM`.
|
|
372
|
+
|
|
373
|
+
Attributes:
|
|
374
|
+
idle (Optional[int]): Set the idle time (last time it was delivered) of the message in milliseconds. If idle
|
|
375
|
+
is not specified, an idle of `0` is assumed, that is, the time count is reset because the message now has a
|
|
376
|
+
new owner trying to process it.
|
|
377
|
+
idle_unix_time (Optional[int]): This is the same as idle but instead of a relative amount of milliseconds,
|
|
378
|
+
it sets the idle time to a specific Unix time (in milliseconds). This is useful in order to rewrite the AOF
|
|
379
|
+
file generating `XCLAIM` commands.
|
|
380
|
+
retry_count (Optional[int]): Set the retry counter to the specified value. This counter is incremented every
|
|
381
|
+
time a message is delivered again. Normally `XCLAIM` does not alter this counter, which is just served to
|
|
382
|
+
clients when the `XPENDING` command is called: this way clients can detect anomalies, like messages that
|
|
383
|
+
are never processed for some reason after a big number of delivery attempts.
|
|
384
|
+
is_force (Optional[bool]): Creates the pending message entry in the PEL even if certain specified IDs are not
|
|
385
|
+
already in the PEL assigned to a different client. However, the message must exist in the stream, otherwise
|
|
386
|
+
the IDs of non-existing messages are ignored.
|
|
387
|
+
"""
|
|
388
|
+
|
|
364
389
|
IDLE_VALKEY_API = "IDLE"
|
|
365
390
|
TIME_VALKEY_API = "TIME"
|
|
366
391
|
RETRY_COUNT_VALKEY_API = "RETRYCOUNT"
|
|
@@ -374,24 +399,6 @@ class StreamClaimOptions:
|
|
|
374
399
|
retry_count: Optional[int] = None,
|
|
375
400
|
is_force: Optional[bool] = False,
|
|
376
401
|
):
|
|
377
|
-
"""
|
|
378
|
-
Options for `XCLAIM`.
|
|
379
|
-
|
|
380
|
-
Args:
|
|
381
|
-
idle (Optional[int]): Set the idle time (last time it was delivered) of the message in milliseconds. If idle
|
|
382
|
-
is not specified, an idle of `0` is assumed, that is, the time count is reset because the message now has a
|
|
383
|
-
new owner trying to process it.
|
|
384
|
-
idle_unix_time (Optional[int]): This is the same as idle but instead of a relative amount of milliseconds,
|
|
385
|
-
it sets the idle time to a specific Unix time (in milliseconds). This is useful in order to rewrite the AOF
|
|
386
|
-
file generating `XCLAIM` commands.
|
|
387
|
-
retry_count (Optional[int]): Set the retry counter to the specified value. This counter is incremented every
|
|
388
|
-
time a message is delivered again. Normally `XCLAIM` does not alter this counter, which is just served to
|
|
389
|
-
clients when the `XPENDING` command is called: this way clients can detect anomalies, like messages that
|
|
390
|
-
are never processed for some reason after a big number of delivery attempts.
|
|
391
|
-
is_force (Optional[bool]): Creates the pending message entry in the PEL even if certain specified IDs are not
|
|
392
|
-
already in the PEL assigned to a different client. However, the message must exist in the stream, otherwise
|
|
393
|
-
the IDs of non-existing messages are ignored.
|
|
394
|
-
"""
|
|
395
402
|
self.idle = idle
|
|
396
403
|
self.idle_unix_time = idle_unix_time
|
|
397
404
|
self.retry_count = retry_count
|