valkey-glide 2.0.0__cp39-cp39-macosx_11_0_arm64.whl → 2.2.5rc1__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.
Files changed (44) hide show
  1. glide/__init__.py +152 -118
  2. glide/async_commands/cluster_commands.py +29 -14
  3. glide/async_commands/core.py +600 -414
  4. glide/async_commands/{server_modules/ft.py → ft.py} +8 -7
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +15 -92
  6. glide/async_commands/standalone_commands.py +10 -51
  7. glide/glide.cpython-39-darwin.so +0 -0
  8. glide/glide.pyi +1 -1
  9. glide/glide_client.py +54 -48
  10. glide/logger.py +3 -3
  11. glide/opentelemetry.py +8 -4
  12. glide_shared/__init__.py +330 -0
  13. glide_shared/commands/__init__.py +0 -0
  14. {glide/async_commands → glide_shared/commands}/batch.py +426 -32
  15. {glide/async_commands → glide_shared/commands}/batch_options.py +1 -1
  16. glide_shared/commands/core_options.py +407 -0
  17. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +3 -3
  18. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +4 -2
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +4 -4
  20. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +4 -2
  21. {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +4 -4
  22. glide_shared/commands/server_modules/json_options.py +93 -0
  23. {glide/async_commands → glide_shared/commands}/sorted_set.py +2 -2
  24. {glide/async_commands → glide_shared/commands}/stream.py +1 -1
  25. {glide → glide_shared}/config.py +315 -60
  26. {glide → glide_shared}/constants.py +3 -3
  27. {glide → glide_shared}/exceptions.py +27 -1
  28. glide_shared/protobuf/command_request_pb2.py +56 -0
  29. glide_shared/protobuf/connection_request_pb2.py +56 -0
  30. {glide → glide_shared}/routes.py +29 -15
  31. {valkey_glide-2.0.0.dist-info → valkey_glide-2.2.5rc1.dist-info}/METADATA +120 -58
  32. valkey_glide-2.2.5rc1.dist-info/RECORD +40 -0
  33. glide/protobuf/command_request_pb2.py +0 -54
  34. glide/protobuf/command_request_pb2.pyi +0 -1193
  35. glide/protobuf/connection_request_pb2.py +0 -52
  36. glide/protobuf/connection_request_pb2.pyi +0 -299
  37. glide/protobuf/response_pb2.pyi +0 -106
  38. valkey_glide-2.0.0.dist-info/RECORD +0 -39
  39. {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
  40. {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
  41. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  42. {glide → glide_shared}/protobuf/response_pb2.py +0 -0
  43. {glide → glide_shared}/protobuf_codec.py +0 -0
  44. {valkey_glide-2.0.0.dist-info → valkey_glide-2.2.5rc1.dist-info}/WHEEL +0 -0
glide/__init__.py CHANGED
@@ -1,18 +1,28 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
 
3
- from glide.async_commands.batch import (
4
- Batch,
5
- ClusterBatch,
6
- ClusterTransaction,
7
- TBatch,
8
- Transaction,
3
+ import sys
4
+ import types
5
+ import warnings
6
+
7
+ from glide.glide import (
8
+ ClusterScanCursor,
9
+ OpenTelemetryConfig,
10
+ OpenTelemetryMetricsConfig,
11
+ OpenTelemetryTracesConfig,
12
+ Script,
9
13
  )
10
- from glide.async_commands.batch_options import (
14
+ from glide_shared import (
15
+ OK,
16
+ TOK,
17
+ AdvancedGlideClientConfiguration,
18
+ AdvancedGlideClusterClientConfiguration,
19
+ AggregationType,
20
+ AllNodes,
21
+ AllPrimaries,
22
+ BackoffStrategy,
23
+ Batch,
11
24
  BatchOptions,
12
25
  BatchRetryStrategy,
13
- ClusterBatchOptions,
14
- )
15
- from glide.async_commands.bitmap import (
16
26
  BitEncoding,
17
27
  BitFieldGet,
18
28
  BitFieldIncrBy,
@@ -25,28 +35,26 @@ from glide.async_commands.bitmap import (
25
35
  BitOffsetMultiplier,
26
36
  BitOverflowControl,
27
37
  BitwiseOperation,
28
- OffsetOptions,
29
- SignedEncoding,
30
- UnsignedEncoding,
31
- )
32
- from glide.async_commands.command_args import Limit, ListDirection, ObjectType, OrderBy
33
- from glide.async_commands.core import (
38
+ ByAddressRoute,
39
+ ClosingError,
40
+ ClusterBatch,
41
+ ClusterBatchOptions,
42
+ ClusterTransaction,
34
43
  ConditionalChange,
35
- CoreCommands,
44
+ ConfigurationError,
45
+ ConnectionError,
46
+ DataType,
47
+ DistanceMetricType,
48
+ ExclusiveIdBound,
49
+ ExecAbortError,
36
50
  ExpireOptions,
37
51
  ExpiryGetEx,
38
52
  ExpirySet,
39
53
  ExpiryType,
40
54
  ExpiryTypeGetEx,
55
+ Field,
56
+ FieldType,
41
57
  FlushMode,
42
- FunctionRestorePolicy,
43
- InfoSection,
44
- InsertPosition,
45
- OnlyIfEqual,
46
- UpdateOptions,
47
- )
48
- from glide.async_commands.server_modules import ft, glide_json, json_batch
49
- from glide.async_commands.server_modules.ft_options.ft_aggregate_options import (
50
58
  FtAggregateApply,
51
59
  FtAggregateClause,
52
60
  FtAggregateFilter,
@@ -54,59 +62,66 @@ from glide.async_commands.server_modules.ft_options.ft_aggregate_options import
54
62
  FtAggregateLimit,
55
63
  FtAggregateOptions,
56
64
  FtAggregateReducer,
65
+ FtAggregateResponse,
57
66
  FtAggregateSortBy,
58
67
  FtAggregateSortProperty,
59
- )
60
- from glide.async_commands.server_modules.ft_options.ft_create_options import (
61
- DataType,
62
- DistanceMetricType,
63
- Field,
64
- FieldType,
65
68
  FtCreateOptions,
66
- NumericField,
67
- TagField,
68
- TextField,
69
- VectorAlgorithm,
70
- VectorField,
71
- VectorFieldAttributes,
72
- VectorFieldAttributesFlat,
73
- VectorFieldAttributesHnsw,
74
- VectorType,
75
- )
76
- from glide.async_commands.server_modules.ft_options.ft_profile_options import (
69
+ FtInfoResponse,
77
70
  FtProfileOptions,
78
- QueryType,
79
- )
80
- from glide.async_commands.server_modules.ft_options.ft_search_options import (
71
+ FtProfileResponse,
81
72
  FtSearchLimit,
82
73
  FtSearchOptions,
83
- ReturnField,
84
- )
85
- from glide.async_commands.server_modules.glide_json import (
86
- JsonArrIndexOptions,
87
- JsonArrPopOptions,
88
- JsonGetOptions,
89
- )
90
- from glide.async_commands.sorted_set import (
91
- AggregationType,
74
+ FtSearchResponse,
75
+ FunctionRestorePolicy,
92
76
  GeoSearchByBox,
93
77
  GeoSearchByRadius,
94
78
  GeoSearchCount,
95
79
  GeospatialData,
96
80
  GeoUnit,
81
+ GlideClientConfiguration,
82
+ GlideClusterClientConfiguration,
83
+ GlideError,
84
+ HashFieldConditionalChange,
85
+ IamAuthConfig,
86
+ IdBound,
97
87
  InfBound,
88
+ InfoSection,
89
+ InsertPosition,
90
+ JsonArrIndexOptions,
91
+ JsonArrPopOptions,
92
+ JsonGetOptions,
98
93
  LexBoundary,
94
+ Limit,
95
+ ListDirection,
96
+ MaxId,
97
+ MinId,
98
+ NodeAddress,
99
+ NumericField,
100
+ ObjectType,
101
+ OffsetOptions,
102
+ OnlyIfEqual,
103
+ OrderBy,
104
+ PeriodicChecksManualInterval,
105
+ PeriodicChecksStatus,
106
+ ProtocolVersion,
107
+ PubSubMsg,
108
+ QueryType,
109
+ RandomNode,
99
110
  RangeByIndex,
100
111
  RangeByLex,
101
112
  RangeByScore,
113
+ ReadFrom,
114
+ RequestError,
115
+ ReturnField,
116
+ Route,
102
117
  ScoreBoundary,
103
118
  ScoreFilter,
104
- )
105
- from glide.async_commands.stream import (
106
- ExclusiveIdBound,
107
- IdBound,
108
- MaxId,
109
- MinId,
119
+ ServerCredentials,
120
+ ServiceType,
121
+ SignedEncoding,
122
+ SlotIdRoute,
123
+ SlotKeyRoute,
124
+ SlotType,
110
125
  StreamAddOptions,
111
126
  StreamClaimOptions,
112
127
  StreamGroupOptions,
@@ -115,84 +130,100 @@ from glide.async_commands.stream import (
115
130
  StreamReadGroupOptions,
116
131
  StreamReadOptions,
117
132
  StreamTrimOptions,
118
- TrimByMaxLen,
119
- TrimByMinId,
120
- )
121
- from glide.config import (
122
- AdvancedGlideClientConfiguration,
123
- AdvancedGlideClusterClientConfiguration,
124
- BackoffStrategy,
125
- GlideClientConfiguration,
126
- GlideClusterClientConfiguration,
127
- NodeAddress,
128
- PeriodicChecksManualInterval,
129
- PeriodicChecksStatus,
130
- ProtocolVersion,
131
- ReadFrom,
132
- ServerCredentials,
133
- TlsAdvancedConfiguration,
134
- )
135
- from glide.constants import (
136
- OK,
137
- TOK,
138
- FtAggregateResponse,
139
- FtInfoResponse,
140
- FtProfileResponse,
141
- FtSearchResponse,
133
+ TagField,
134
+ TBatch,
142
135
  TClusterResponse,
143
136
  TEncodable,
137
+ TextField,
144
138
  TFunctionListResponse,
145
139
  TFunctionStatsFullResponse,
146
140
  TFunctionStatsSingleNodeResponse,
141
+ TimeoutError,
147
142
  TJsonResponse,
148
143
  TJsonUniversalResponse,
144
+ TlsAdvancedConfiguration,
145
+ Transaction,
149
146
  TResult,
147
+ TrimByMaxLen,
148
+ TrimByMinId,
150
149
  TSingleNodeRoute,
151
150
  TXInfoStreamFullResponse,
152
151
  TXInfoStreamResponse,
153
- )
154
- from glide.exceptions import (
155
- ClosingError,
156
- ConfigurationError,
157
- ConnectionError,
158
- ExecAbortError,
159
- GlideError,
160
- RequestError,
161
- TimeoutError,
162
- )
163
- from glide.glide_client import GlideClient, GlideClusterClient, TGlideClient
164
- from glide.logger import Level as LogLevel
165
- from glide.logger import Logger
166
- from glide.routes import (
167
- AllNodes,
168
- AllPrimaries,
169
- ByAddressRoute,
170
- RandomNode,
171
- Route,
172
- SlotIdRoute,
173
- SlotKeyRoute,
174
- SlotType,
152
+ UnsignedEncoding,
153
+ UpdateOptions,
154
+ VectorAlgorithm,
155
+ VectorField,
156
+ VectorFieldAttributes,
157
+ VectorFieldAttributesFlat,
158
+ VectorFieldAttributesHnsw,
159
+ VectorType,
160
+ json_batch,
175
161
  )
176
162
 
177
- from .glide import (
178
- ClusterScanCursor,
179
- OpenTelemetryConfig,
180
- OpenTelemetryMetricsConfig,
181
- OpenTelemetryTracesConfig,
182
- Script,
183
- )
163
+ from .async_commands import ft, glide_json
164
+ from .glide_client import GlideClient, GlideClusterClient, TGlideClient
165
+ from .logger import Level as LogLevel
166
+ from .logger import Logger
167
+
168
+ _glide_module = sys.modules[__name__]
169
+
170
+ _legacy_modules = [
171
+ "glide.exceptions",
172
+ "glide.config",
173
+ "glide.constants",
174
+ "glide.routes",
175
+ "glide.async_commands",
176
+ "glide.async_commands.batch",
177
+ "glide.async_commands.batch_options",
178
+ "glide.async_commands.bitmap",
179
+ "glide.async_commands.command_args",
180
+ "glide.async_commands.server_modules",
181
+ "glide.async_commands.server_modules.ft_options",
182
+ "glide.async_commands.server_modules.ft_options.ft_aggregate_options",
183
+ "glide.async_commands.server_modules.ft_options.ft_create_options",
184
+ "glide.async_commands.server_modules.ft_options.ft_profile_options",
185
+ "glide.async_commands.server_modules.ft_options.ft_search_options",
186
+ "glide.async_commands.server_modules.glide_json",
187
+ "glide.async_commands.sorted_set",
188
+ "glide.async_commands.stream",
189
+ ]
190
+
191
+
192
+ class _LegacyModule(types.ModuleType):
193
+ """Proxy for a deprecated module that warns when first accessed."""
194
+
195
+ def __init__(self, name):
196
+ super().__init__(name)
197
+ self._warned = False
184
198
 
185
- PubSubMsg = CoreCommands.PubSubMsg
199
+ def __getattr__(self, name):
200
+ if not self._warned:
201
+ warnings.warn(
202
+ f"Importing from '{self.__name__}' is deprecated. "
203
+ f"Please import directly from 'glide' instead.",
204
+ DeprecationWarning,
205
+ stacklevel=2,
206
+ )
207
+ self._warned = True
208
+
209
+ # Access the attribute from the real top-level glide module
210
+ return getattr(_glide_module, name)
211
+
212
+
213
+ # Replace old modules with lazy proxy modules
214
+ for old_name in _legacy_modules:
215
+ if old_name not in sys.modules:
216
+ sys.modules[old_name] = _LegacyModule(old_name)
186
217
 
187
218
  __all__ = [
188
219
  # Client
220
+ "TGlideClient",
189
221
  "GlideClient",
190
222
  "GlideClusterClient",
191
223
  "Batch",
192
224
  "ClusterBatch",
193
225
  "ClusterTransaction",
194
226
  "Transaction",
195
- "TGlideClient",
196
227
  "TBatch",
197
228
  # Batch Options
198
229
  "BatchOptions",
@@ -206,13 +237,16 @@ __all__ = [
206
237
  "BackoffStrategy",
207
238
  "ReadFrom",
208
239
  "ServerCredentials",
240
+ "ServiceType",
241
+ "IamAuthConfig",
209
242
  "NodeAddress",
210
243
  "OpenTelemetryConfig",
211
- "OpenTelemetryTracesConfig",
212
244
  "OpenTelemetryMetricsConfig",
245
+ "OpenTelemetryTracesConfig",
213
246
  "ProtocolVersion",
214
247
  "PeriodicChecksManualInterval",
215
248
  "PeriodicChecksStatus",
249
+ "TlsAdvancedConfiguration",
216
250
  # Response
217
251
  "OK",
218
252
  "TClusterResponse",
@@ -224,7 +258,6 @@ __all__ = [
224
258
  "TJsonUniversalResponse",
225
259
  "TOK",
226
260
  "TResult",
227
- "TlsAdvancedConfiguration",
228
261
  "TXInfoStreamFullResponse",
229
262
  "TXInfoStreamResponse",
230
263
  "FtAggregateResponse",
@@ -263,11 +296,11 @@ __all__ = [
263
296
  "GeoSearchCount",
264
297
  "GeoUnit",
265
298
  "GeospatialData",
299
+ "HashFieldConditionalChange",
266
300
  "AggregationType",
267
301
  "InfBound",
268
302
  "InfoSection",
269
303
  "InsertPosition",
270
- "ft",
271
304
  "LexBoundary",
272
305
  "Limit",
273
306
  "ListDirection",
@@ -323,6 +356,7 @@ __all__ = [
323
356
  "RequestError",
324
357
  "TimeoutError",
325
358
  # Ft
359
+ "ft",
326
360
  "DataType",
327
361
  "DistanceMetricType",
328
362
  "Field",
@@ -4,16 +4,16 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Dict, List, Mapping, Optional, Union, cast
6
6
 
7
- from glide.async_commands.batch import ClusterBatch
8
- from glide.async_commands.batch_options import ClusterBatchOptions
9
- from glide.async_commands.command_args import ObjectType
10
- from glide.async_commands.core import (
11
- CoreCommands,
7
+ from glide.glide import ClusterScanCursor, Script
8
+ from glide_shared.commands.batch import ClusterBatch
9
+ from glide_shared.commands.batch_options import ClusterBatchOptions
10
+ from glide_shared.commands.command_args import ObjectType
11
+ from glide_shared.commands.core_options import (
12
12
  FlushMode,
13
13
  FunctionRestorePolicy,
14
14
  InfoSection,
15
15
  )
16
- from glide.constants import (
16
+ from glide_shared.constants import (
17
17
  TOK,
18
18
  TClusterResponse,
19
19
  TEncodable,
@@ -21,11 +21,11 @@ from glide.constants import (
21
21
  TFunctionStatsSingleNodeResponse,
22
22
  TResult,
23
23
  )
24
- from glide.exceptions import RequestError
25
- from glide.protobuf.command_request_pb2 import RequestType
26
- from glide.routes import Route
24
+ from glide_shared.exceptions import RequestError
25
+ from glide_shared.protobuf.command_request_pb2 import RequestType
26
+ from glide_shared.routes import Route
27
27
 
28
- from ..glide import ClusterScanCursor, Script
28
+ from .core import CoreCommands
29
29
 
30
30
 
31
31
  class ClusterCommands(CoreCommands):
@@ -1066,11 +1066,17 @@ class ClusterCommands(CoreCommands):
1066
1066
  self,
1067
1067
  source: TEncodable,
1068
1068
  destination: TEncodable,
1069
+ # TODO next major release the arguments replace and destinationDB must have their order
1070
+ # swapped to align with the standalone order.
1071
+ # At the moment of the patch release 2.1.1. we can't have a breaking change
1069
1072
  replace: Optional[bool] = None,
1073
+ destinationDB: Optional[int] = None,
1070
1074
  ) -> bool:
1071
1075
  """
1072
- Copies the value stored at the `source` to the `destination` key. When `replace` is True,
1073
- removes the `destination` key first if it already exists, otherwise performs no action.
1076
+ Copies the value stored at the `source` to the `destination` key. If `destinationDB`
1077
+ is specified, the value will be copied to the database specified by `destinationDB`,
1078
+ otherwise the current database will be used. When `replace` is True, removes the
1079
+ `destination` key first if it already exists, otherwise performs no action.
1074
1080
 
1075
1081
  See [valkey.io](https://valkey.io/commands/copy) for more details.
1076
1082
 
@@ -1081,6 +1087,7 @@ class ClusterCommands(CoreCommands):
1081
1087
  source (TEncodable): The key to the source value.
1082
1088
  destination (TEncodable): The key where the value should be copied to.
1083
1089
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
1090
+ destinationDB (Optional[int]): The alternative logical database index for the destination key.
1084
1091
 
1085
1092
  Returns:
1086
1093
  bool: True if the source was copied. Otherwise, returns False.
@@ -1089,12 +1096,20 @@ class ClusterCommands(CoreCommands):
1089
1096
  >>> await client.set("source", "sheep")
1090
1097
  >>> await client.copy(b"source", b"destination")
1091
1098
  True # Source was copied
1099
+ >>> await client.copy(b"source", b"destination", destinationDB=1)
1100
+ True # Source was copied to DB 1
1101
+ >>> await client.select(1)
1092
1102
  >>> await client.get("destination")
1093
1103
  b"sheep"
1094
1104
 
1095
1105
  Since: Valkey version 6.2.0.
1106
+ The destinationDB argument is available since Valkey 9.0.0
1096
1107
  """
1108
+
1109
+ # Build command arguments
1097
1110
  args: List[TEncodable] = [source, destination]
1111
+ if destinationDB is not None:
1112
+ args.extend(["DB", str(destinationDB)])
1098
1113
  if replace is True:
1099
1114
  args.append("REPLACE")
1100
1115
  return cast(
@@ -1141,7 +1156,7 @@ class ClusterCommands(CoreCommands):
1141
1156
  args.extend(["VERSION", str(version)])
1142
1157
  if parameters:
1143
1158
  for var in parameters:
1144
- args.extend(str(var))
1159
+ args.append(str(var))
1145
1160
  return cast(
1146
1161
  TClusterResponse[bytes],
1147
1162
  await self._execute_command(RequestType.Lolwut, args, route),
@@ -1421,7 +1436,7 @@ class ClusterCommands(CoreCommands):
1421
1436
 
1422
1437
  Examples:
1423
1438
  >>> lua_script = Script("return { KEYS[1], ARGV[1] }")
1424
- >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"] );
1439
+ >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"])
1425
1440
  [b"foo", b"bar"]
1426
1441
  """
1427
1442
  return await self._execute_script(script.get_hash(), keys, args)