valkey-glide 2.1.0rc3__cp39-cp39-macosx_11_0_arm64.whl → 2.1.0rc5__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.

Potentially problematic release.


This version of valkey-glide might be problematic. Click here for more details.

@@ -166,6 +166,28 @@ class StandaloneCommands(CoreCommands):
166
166
  """
167
167
  Change the currently selected database.
168
168
 
169
+ **WARNING**: This command is NOT RECOMMENDED for production use.
170
+ Upon reconnection, the client will revert to the database_id specified
171
+ in the client configuration (default: 0), NOT the database selected
172
+ via this command.
173
+
174
+ **RECOMMENDED APPROACH**: Use the database_id parameter in client
175
+ configuration instead:
176
+
177
+ ```python
178
+ client = await GlideClient.create_client(
179
+ GlideClientConfiguration(
180
+ addresses=[NodeAddress("localhost", 6379)],
181
+ database_id=5 # Recommended: persists across reconnections
182
+ )
183
+ )
184
+ ```
185
+
186
+ **RECONNECTION BEHAVIOR**: After any reconnection (due to network issues,
187
+ timeouts, etc.), the client will automatically revert to the database_id
188
+ specified during client creation, losing any database selection made via
189
+ this SELECT command.
190
+
169
191
  See [valkey.io](https://valkey.io/commands/select/) for details.
170
192
 
171
193
  Args:
Binary file
glide_shared/config.py CHANGED
@@ -249,6 +249,8 @@ class BaseClientConfiguration:
249
249
  reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of
250
250
  connection failures.
251
251
  If not set, a default backoff strategy will be used.
252
+ database_id (Optional[int]): Index of the logical database to connect to.
253
+ Must be a non-negative integer.If not set, the client will connect to database 0.
252
254
  client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command
253
255
  during connection establishment.
254
256
  protocol (ProtocolVersion): Serialization protocol to be used. If not set, `RESP3` will be used.
@@ -292,6 +294,7 @@ class BaseClientConfiguration:
292
294
  read_from: ReadFrom = ReadFrom.PRIMARY,
293
295
  request_timeout: Optional[int] = None,
294
296
  reconnect_strategy: Optional[BackoffStrategy] = None,
297
+ database_id: Optional[int] = None,
295
298
  client_name: Optional[str] = None,
296
299
  protocol: ProtocolVersion = ProtocolVersion.RESP3,
297
300
  inflight_requests_limit: Optional[int] = None,
@@ -305,6 +308,7 @@ class BaseClientConfiguration:
305
308
  self.read_from = read_from
306
309
  self.request_timeout = request_timeout
307
310
  self.reconnect_strategy = reconnect_strategy
311
+ self.database_id = database_id
308
312
  self.client_name = client_name
309
313
  self.protocol = protocol
310
314
  self.inflight_requests_limit = inflight_requests_limit
@@ -322,6 +326,39 @@ class BaseClientConfiguration:
322
326
  "client_az must be set when read_from is set to AZ_AFFINITY_REPLICAS_AND_PRIMARY"
323
327
  )
324
328
 
329
+ def _set_addresses_in_request(self, request: ConnectionRequest) -> None:
330
+ """Set addresses in the protobuf request."""
331
+ for address in self.addresses:
332
+ address_info = request.addresses.add()
333
+ address_info.host = address.host
334
+ address_info.port = address.port
335
+
336
+ def _set_reconnect_strategy_in_request(self, request: ConnectionRequest) -> None:
337
+ """Set reconnect strategy in the protobuf request."""
338
+ if not self.reconnect_strategy:
339
+ return
340
+
341
+ request.connection_retry_strategy.number_of_retries = (
342
+ self.reconnect_strategy.num_of_retries
343
+ )
344
+ request.connection_retry_strategy.factor = self.reconnect_strategy.factor
345
+ request.connection_retry_strategy.exponent_base = (
346
+ self.reconnect_strategy.exponent_base
347
+ )
348
+ if self.reconnect_strategy.jitter_percent is not None:
349
+ request.connection_retry_strategy.jitter_percent = (
350
+ self.reconnect_strategy.jitter_percent
351
+ )
352
+
353
+ def _set_credentials_in_request(self, request: ConnectionRequest) -> None:
354
+ """Set credentials in the protobuf request."""
355
+ if not self.credentials:
356
+ return
357
+
358
+ if self.credentials.username:
359
+ request.authentication_info.username = self.credentials.username
360
+ request.authentication_info.password = self.credentials.password
361
+
325
362
  def _create_a_protobuf_conn_request(
326
363
  self, cluster_mode: bool = False
327
364
  ) -> ConnectionRequest:
@@ -335,44 +372,34 @@ class BaseClientConfiguration:
335
372
  ConnectionRequest: Protobuf ConnectionRequest.
336
373
  """
337
374
  request = ConnectionRequest()
338
- for address in self.addresses:
339
- address_info = request.addresses.add()
340
- address_info.host = address.host
341
- address_info.port = address.port
375
+
376
+ # Set basic configuration
377
+ self._set_addresses_in_request(request)
342
378
  request.tls_mode = TlsMode.SecureTls if self.use_tls else TlsMode.NoTls
343
379
  request.read_from = self.read_from.value
380
+ request.cluster_mode_enabled = cluster_mode
381
+ request.protocol = self.protocol.value
382
+
383
+ # Set optional configuration
344
384
  if self.request_timeout:
345
385
  request.request_timeout = self.request_timeout
346
- if self.reconnect_strategy:
347
- request.connection_retry_strategy.number_of_retries = (
348
- self.reconnect_strategy.num_of_retries
349
- )
350
- request.connection_retry_strategy.factor = self.reconnect_strategy.factor
351
- request.connection_retry_strategy.exponent_base = (
352
- self.reconnect_strategy.exponent_base
353
- )
354
- if self.reconnect_strategy.jitter_percent is not None:
355
- request.connection_retry_strategy.jitter_percent = (
356
- self.reconnect_strategy.jitter_percent
357
- )
358
386
 
359
- request.cluster_mode_enabled = True if cluster_mode else False
360
- if self.credentials:
361
- if self.credentials.username:
362
- request.authentication_info.username = self.credentials.username
363
- request.authentication_info.password = self.credentials.password
387
+ self._set_reconnect_strategy_in_request(request)
388
+ self._set_credentials_in_request(request)
389
+
364
390
  if self.client_name:
365
391
  request.client_name = self.client_name
366
- request.protocol = self.protocol.value
367
392
  if self.inflight_requests_limit:
368
393
  request.inflight_requests_limit = self.inflight_requests_limit
369
394
  if self.client_az:
370
395
  request.client_az = self.client_az
396
+ if self.database_id is not None:
397
+ request.database_id = self.database_id
371
398
  if self.advanced_config:
372
399
  self.advanced_config._create_a_protobuf_conn_request(request)
373
-
374
400
  if self.lazy_connect is not None:
375
401
  request.lazy_connect = self.lazy_connect
402
+
376
403
  return request
377
404
 
378
405
  def _is_pubsub_configured(self) -> bool:
@@ -425,7 +452,7 @@ class GlideClientConfiguration(BaseClientConfiguration):
425
452
  reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of
426
453
  connection failures.
427
454
  If not set, a default backoff strategy will be used.
428
- database_id (Optional[int]): index of the logical database to connect to.
455
+ database_id (Optional[int]): Index of the logical database to connect to.
429
456
  client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during
430
457
  connection establishment.
431
458
  protocol (ProtocolVersion): The version of the RESP protocol to communicate with the server.
@@ -500,6 +527,7 @@ class GlideClientConfiguration(BaseClientConfiguration):
500
527
  read_from=read_from,
501
528
  request_timeout=request_timeout,
502
529
  reconnect_strategy=reconnect_strategy,
530
+ database_id=database_id,
503
531
  client_name=client_name,
504
532
  protocol=protocol,
505
533
  inflight_requests_limit=inflight_requests_limit,
@@ -507,7 +535,6 @@ class GlideClientConfiguration(BaseClientConfiguration):
507
535
  advanced_config=advanced_config,
508
536
  lazy_connect=lazy_connect,
509
537
  )
510
- self.database_id = database_id
511
538
  self.pubsub_subscriptions = pubsub_subscriptions
512
539
 
513
540
  def _create_a_protobuf_conn_request(
@@ -515,8 +542,6 @@ class GlideClientConfiguration(BaseClientConfiguration):
515
542
  ) -> ConnectionRequest:
516
543
  assert cluster_mode is False
517
544
  request = super()._create_a_protobuf_conn_request(cluster_mode)
518
- if self.database_id:
519
- request.database_id = self.database_id
520
545
 
521
546
  if self.pubsub_subscriptions:
522
547
  if self.protocol == ProtocolVersion.RESP2:
@@ -592,6 +617,7 @@ class GlideClusterClientConfiguration(BaseClientConfiguration):
592
617
  reconnect_strategy (Optional[BackoffStrategy]): Strategy used to determine how and when to reconnect, in case of
593
618
  connection failures.
594
619
  If not set, a default backoff strategy will be used.
620
+ database_id (Optional[int]): Index of the logical database to connect to.
595
621
  client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during
596
622
  connection establishment.
597
623
  protocol (ProtocolVersion): The version of the RESP protocol to communicate with the server.
@@ -661,6 +687,7 @@ class GlideClusterClientConfiguration(BaseClientConfiguration):
661
687
  read_from: ReadFrom = ReadFrom.PRIMARY,
662
688
  request_timeout: Optional[int] = None,
663
689
  reconnect_strategy: Optional[BackoffStrategy] = None,
690
+ database_id: Optional[int] = None,
664
691
  client_name: Optional[str] = None,
665
692
  protocol: ProtocolVersion = ProtocolVersion.RESP3,
666
693
  periodic_checks: Union[
@@ -679,6 +706,7 @@ class GlideClusterClientConfiguration(BaseClientConfiguration):
679
706
  read_from=read_from,
680
707
  request_timeout=request_timeout,
681
708
  reconnect_strategy=reconnect_strategy,
709
+ database_id=database_id,
682
710
  client_name=client_name,
683
711
  protocol=protocol,
684
712
  inflight_requests_limit=inflight_requests_limit,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: valkey-glide
3
- Version: 2.1.0rc3
3
+ Version: 2.1.0rc5
4
4
  Classifier: Topic :: Database
5
5
  Classifier: Topic :: Utilities
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -1,10 +1,10 @@
1
- valkey_glide-2.1.0rc3.dist-info/METADATA,sha256=7Aa9YU4k73bvUkMttcOMCTNM9lTJQzUIPP9Ve0WdxE0,6978
2
- valkey_glide-2.1.0rc3.dist-info/WHEEL,sha256=SjFvs0za84r93yXv_seM90QIJLVMin7Qs7nbzy5Blh4,104
1
+ valkey_glide-2.1.0rc5.dist-info/METADATA,sha256=KDfjUdkQ7nYF7E5_41YdF8MxSGVYFrgPOyEjxV0PYgw,6978
2
+ valkey_glide-2.1.0rc5.dist-info/WHEEL,sha256=SjFvs0za84r93yXv_seM90QIJLVMin7Qs7nbzy5Blh4,104
3
3
  glide/async_commands/glide_json.py,sha256=H5dnB4vJkGPpNXJZhhVyPQoTSbkN_chq5Xw6tkP0wMQ,60410
4
4
  glide/async_commands/ft.py,sha256=1v96sBCgiXtPbj85ZurY3ruLCmok3cPoaIXSiJBEv9Y,16849
5
5
  glide/async_commands/__init__.py,sha256=_tbTAFATlzp4L2qe-H77PpAQK-16VsV-y7uKNUKLC_o,136
6
6
  glide/async_commands/core.py,sha256=RdfOTxpvgY4sQsSL3PqHi-05CV_AmDhsZad-ALg4EHU,328057
7
- glide/async_commands/standalone_commands.py,sha256=y6hH6iE4ngAJlB9JTa1y_ZHRmM1MDMvWQKOHghyN73E,39450
7
+ glide/async_commands/standalone_commands.py,sha256=6oPesnC8WK816JbBySUZ9dSXPbdtN0dvd8rRde646NQ,40364
8
8
  glide/async_commands/cluster_commands.py,sha256=Lji6eo2LaoXwy4Ha3e6bcGOHyMQHdDBiSQLt1kf9gGo,60129
9
9
  glide/__init__.py,sha256=r0VyTcuIdVzXTTZW6TmWwCsTCIg54ciyba1iDM8PFVQ,7055
10
10
  glide/glide.pyi,sha256=6JIpAeADQ-1fU1Mp99pyh7aJORDxAAdtQebV5aByIVI,2093
@@ -27,7 +27,7 @@ glide_shared/commands/server_modules/json_batch.py,sha256=uqkLXPCOkzp53GfffnII1x
27
27
  glide_shared/commands/server_modules/json_options.py,sha256=0dFk3EEtcERpmkNoO8930MqfEHLVaQRBRcg3CpL7nmE,3042
28
28
  glide_shared/commands/sorted_set.py,sha256=hnXud0Ewn1uBdM6T2xzfCneZWfTeP-2U0XfEDGNCqlI,11466
29
29
  glide_shared/commands/stream.py,sha256=MlllDP3teVX8BOB4ANb0JFC4RkUp8SQLCGlGMSPU_s4,15589
30
- glide_shared/config.py,sha256=UvbRFMSVC8rVux895RG9mLsiIC_8waavc3OfM5bnUQs,33108
30
+ glide_shared/config.py,sha256=FUm6msEcJZTPqHaiN5e1g-7IjD2QHcOOBCYN-VdJFHk,34155
31
31
  glide_shared/constants.py,sha256=pS7Xbjvq_qG3mlolVf51cCAGzXRhGdhvGIs2QK3R_b4,4375
32
32
  glide_shared/exceptions.py,sha256=Z_szeAE-m1gsoBr5bPQymF6W6wiaunoHvBrt1dHbiYw,1852
33
33
  glide_shared/protobuf/command_request_pb2.py,sha256=AHS04ukttbfhXQtEsW5_wAPUS6TzGMd5uqcrSt7lWJo,19320
@@ -35,5 +35,5 @@ glide_shared/protobuf/connection_request_pb2.py,sha256=b3jDmMetSHUrZGmQd8b5DooZZ
35
35
  glide_shared/protobuf/response_pb2.py,sha256=oT2GHUwjrxvBVdINRKCvb3_BFN0Fq2wqwHbTj7KAX2E,2110
36
36
  glide_shared/protobuf_codec.py,sha256=xwt4-D4WbvNIY_vjOd-00c73HOyNjWq7nN-Z718PBVA,3667
37
37
  glide_shared/routes.py,sha256=HFccxCzXQXSi6Y1HFsRUm9ZcbJgCrar6y6uOWpGJWe0,4746
38
- glide/glide.cpython-39-darwin.so,sha256=QFqBmVV7qftyvf3c4etDa-7YbWj67mOFhHSvB6H7YpM,9924624
39
- valkey_glide-2.1.0rc3.dist-info/RECORD,,
38
+ glide/glide.cpython-39-darwin.so,sha256=AR7UjQzfzelUG5Vh0tbN9dB7QmJyLBy3TFFtASu1d3A,9891648
39
+ valkey_glide-2.1.0rc5.dist-info/RECORD,,