redis 7.0.0b1__py3-none-any.whl → 7.0.0b3__py3-none-any.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 (43) hide show
  1. redis/__init__.py +1 -1
  2. redis/_parsers/base.py +36 -22
  3. redis/asyncio/client.py +20 -6
  4. redis/asyncio/cluster.py +11 -2
  5. redis/asyncio/connection.py +61 -1
  6. redis/asyncio/http/__init__.py +0 -0
  7. redis/asyncio/http/http_client.py +265 -0
  8. redis/asyncio/multidb/__init__.py +0 -0
  9. redis/asyncio/multidb/client.py +528 -0
  10. redis/asyncio/multidb/command_executor.py +339 -0
  11. redis/asyncio/multidb/config.py +210 -0
  12. redis/asyncio/multidb/database.py +69 -0
  13. redis/asyncio/multidb/event.py +84 -0
  14. redis/asyncio/multidb/failover.py +125 -0
  15. redis/asyncio/multidb/failure_detector.py +38 -0
  16. redis/asyncio/multidb/healthcheck.py +292 -0
  17. redis/background.py +204 -0
  18. redis/client.py +41 -18
  19. redis/cluster.py +5 -1
  20. redis/commands/core.py +10 -3
  21. redis/connection.py +206 -151
  22. redis/data_structure.py +81 -0
  23. redis/event.py +84 -10
  24. redis/http/__init__.py +0 -0
  25. redis/http/http_client.py +425 -0
  26. redis/{maintenance_events.py → maint_notifications.py} +154 -140
  27. redis/multidb/__init__.py +0 -0
  28. redis/multidb/circuit.py +144 -0
  29. redis/multidb/client.py +524 -0
  30. redis/multidb/command_executor.py +350 -0
  31. redis/multidb/config.py +207 -0
  32. redis/multidb/database.py +130 -0
  33. redis/multidb/event.py +89 -0
  34. redis/multidb/exception.py +17 -0
  35. redis/multidb/failover.py +125 -0
  36. redis/multidb/failure_detector.py +104 -0
  37. redis/multidb/healthcheck.py +289 -0
  38. redis/retry.py +14 -1
  39. redis/utils.py +14 -0
  40. {redis-7.0.0b1.dist-info → redis-7.0.0b3.dist-info}/METADATA +3 -1
  41. {redis-7.0.0b1.dist-info → redis-7.0.0b3.dist-info}/RECORD +43 -17
  42. {redis-7.0.0b1.dist-info → redis-7.0.0b3.dist-info}/WHEEL +0 -0
  43. {redis-7.0.0b1.dist-info → redis-7.0.0b3.dist-info}/licenses/LICENSE +0 -0
redis/client.py CHANGED
@@ -56,9 +56,9 @@ from redis.exceptions import (
56
56
  WatchError,
57
57
  )
58
58
  from redis.lock import Lock
59
- from redis.maintenance_events import (
60
- MaintenanceEventPoolHandler,
61
- MaintenanceEventsConfig,
59
+ from redis.maint_notifications import (
60
+ MaintNotificationsConfig,
61
+ MaintNotificationsPoolHandler,
62
62
  )
63
63
  from redis.retry import Retry
64
64
  from redis.utils import (
@@ -224,6 +224,8 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
224
224
  ssl_keyfile: Optional[str] = None,
225
225
  ssl_certfile: Optional[str] = None,
226
226
  ssl_cert_reqs: Union[str, "ssl.VerifyMode"] = "required",
227
+ ssl_include_verify_flags: Optional[List["ssl.VerifyFlags"]] = None,
228
+ ssl_exclude_verify_flags: Optional[List["ssl.VerifyFlags"]] = None,
227
229
  ssl_ca_certs: Optional[str] = None,
228
230
  ssl_ca_path: Optional[str] = None,
229
231
  ssl_ca_data: Optional[str] = None,
@@ -248,7 +250,7 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
248
250
  cache: Optional[CacheInterface] = None,
249
251
  cache_config: Optional[CacheConfig] = None,
250
252
  event_dispatcher: Optional[EventDispatcher] = None,
251
- maintenance_events_config: Optional[MaintenanceEventsConfig] = None,
253
+ maint_notifications_config: Optional[MaintNotificationsConfig] = None,
252
254
  ) -> None:
253
255
  """
254
256
  Initialize a new Redis client.
@@ -330,6 +332,8 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
330
332
  "ssl_keyfile": ssl_keyfile,
331
333
  "ssl_certfile": ssl_certfile,
332
334
  "ssl_cert_reqs": ssl_cert_reqs,
335
+ "ssl_include_verify_flags": ssl_include_verify_flags,
336
+ "ssl_exclude_verify_flags": ssl_exclude_verify_flags,
333
337
  "ssl_ca_certs": ssl_ca_certs,
334
338
  "ssl_ca_data": ssl_ca_data,
335
339
  "ssl_check_hostname": ssl_check_hostname,
@@ -373,22 +377,22 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
373
377
  ]:
374
378
  raise RedisError("Client caching is only supported with RESP version 3")
375
379
 
376
- if maintenance_events_config and self.connection_pool.get_protocol() not in [
380
+ if maint_notifications_config and self.connection_pool.get_protocol() not in [
377
381
  3,
378
382
  "3",
379
383
  ]:
380
384
  raise RedisError(
381
385
  "Push handlers on connection are only supported with RESP version 3"
382
386
  )
383
- if maintenance_events_config and maintenance_events_config.enabled:
384
- self.maintenance_events_pool_handler = MaintenanceEventPoolHandler(
385
- self.connection_pool, maintenance_events_config
387
+ if maint_notifications_config and maint_notifications_config.enabled:
388
+ self.maint_notifications_pool_handler = MaintNotificationsPoolHandler(
389
+ self.connection_pool, maint_notifications_config
386
390
  )
387
- self.connection_pool.set_maintenance_events_pool_handler(
388
- self.maintenance_events_pool_handler
391
+ self.connection_pool.set_maint_notifications_pool_handler(
392
+ self.maint_notifications_pool_handler
389
393
  )
390
394
  else:
391
- self.maintenance_events_pool_handler = None
395
+ self.maint_notifications_pool_handler = None
392
396
 
393
397
  self.single_connection_lock = threading.RLock()
394
398
  self.connection = None
@@ -587,15 +591,15 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
587
591
  return Monitor(self.connection_pool)
588
592
 
589
593
  def client(self):
590
- maintenance_events_config = (
594
+ maint_notifications_config = (
591
595
  None
592
- if self.maintenance_events_pool_handler is None
593
- else self.maintenance_events_pool_handler.config
596
+ if self.maint_notifications_pool_handler is None
597
+ else self.maint_notifications_pool_handler.config
594
598
  )
595
599
  return self.__class__(
596
600
  connection_pool=self.connection_pool,
597
601
  single_connection_client=True,
598
- maintenance_events_config=maintenance_events_config,
602
+ maint_notifications_config=maint_notifications_config,
599
603
  )
600
604
 
601
605
  def __enter__(self):
@@ -1182,7 +1186,10 @@ class PubSub:
1182
1186
 
1183
1187
  def ping(self, message: Union[str, None] = None) -> bool:
1184
1188
  """
1185
- Ping the Redis server
1189
+ Ping the Redis server to test connectivity.
1190
+
1191
+ Sends a PING command to the Redis server and returns True if the server
1192
+ responds with "PONG".
1186
1193
  """
1187
1194
  args = ["PING", message] if message is not None else ["PING"]
1188
1195
  return self.execute_command(*args)
@@ -1267,6 +1274,8 @@ class PubSub:
1267
1274
  sleep_time: float = 0.0,
1268
1275
  daemon: bool = False,
1269
1276
  exception_handler: Optional[Callable] = None,
1277
+ pubsub=None,
1278
+ sharded_pubsub: bool = False,
1270
1279
  ) -> "PubSubWorkerThread":
1271
1280
  for channel, handler in self.channels.items():
1272
1281
  if handler is None:
@@ -1280,8 +1289,13 @@ class PubSub:
1280
1289
  f"Shard Channel: '{s_channel}' has no handler registered"
1281
1290
  )
1282
1291
 
1292
+ pubsub = self if pubsub is None else pubsub
1283
1293
  thread = PubSubWorkerThread(
1284
- self, sleep_time, daemon=daemon, exception_handler=exception_handler
1294
+ pubsub,
1295
+ sleep_time,
1296
+ daemon=daemon,
1297
+ exception_handler=exception_handler,
1298
+ sharded_pubsub=sharded_pubsub,
1285
1299
  )
1286
1300
  thread.start()
1287
1301
  return thread
@@ -1296,12 +1310,14 @@ class PubSubWorkerThread(threading.Thread):
1296
1310
  exception_handler: Union[
1297
1311
  Callable[[Exception, "PubSub", "PubSubWorkerThread"], None], None
1298
1312
  ] = None,
1313
+ sharded_pubsub: bool = False,
1299
1314
  ):
1300
1315
  super().__init__()
1301
1316
  self.daemon = daemon
1302
1317
  self.pubsub = pubsub
1303
1318
  self.sleep_time = sleep_time
1304
1319
  self.exception_handler = exception_handler
1320
+ self.sharded_pubsub = sharded_pubsub
1305
1321
  self._running = threading.Event()
1306
1322
 
1307
1323
  def run(self) -> None:
@@ -1312,7 +1328,14 @@ class PubSubWorkerThread(threading.Thread):
1312
1328
  sleep_time = self.sleep_time
1313
1329
  while self._running.is_set():
1314
1330
  try:
1315
- pubsub.get_message(ignore_subscribe_messages=True, timeout=sleep_time)
1331
+ if not self.sharded_pubsub:
1332
+ pubsub.get_message(
1333
+ ignore_subscribe_messages=True, timeout=sleep_time
1334
+ )
1335
+ else:
1336
+ pubsub.get_sharded_message(
1337
+ ignore_subscribe_messages=True, timeout=sleep_time
1338
+ )
1316
1339
  except BaseException as e:
1317
1340
  if self.exception_handler is None:
1318
1341
  raise
redis/cluster.py CHANGED
@@ -184,6 +184,8 @@ REDIS_ALLOWED_KEYS = (
184
184
  "ssl_ca_data",
185
185
  "ssl_certfile",
186
186
  "ssl_cert_reqs",
187
+ "ssl_include_verify_flags",
188
+ "ssl_exclude_verify_flags",
187
189
  "ssl_keyfile",
188
190
  "ssl_password",
189
191
  "ssl_check_hostname",
@@ -693,6 +695,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands):
693
695
  self._event_dispatcher = EventDispatcher()
694
696
  else:
695
697
  self._event_dispatcher = event_dispatcher
698
+ self.startup_nodes = startup_nodes
696
699
  self.nodes_manager = NodesManager(
697
700
  startup_nodes=startup_nodes,
698
701
  from_url=from_url,
@@ -3162,7 +3165,8 @@ class TransactionStrategy(AbstractStrategy):
3162
3165
  self._nodes_manager.initialize()
3163
3166
  self.reinitialize_counter = 0
3164
3167
  else:
3165
- self._nodes_manager.update_moved_exception(error)
3168
+ if isinstance(error, AskError):
3169
+ self._nodes_manager.update_moved_exception(error)
3166
3170
 
3167
3171
  self._executing = False
3168
3172
 
redis/commands/core.py CHANGED
@@ -1210,11 +1210,18 @@ class ManagementCommands(CommandsProtocol):
1210
1210
  """
1211
1211
  return self.execute_command("LATENCY RESET", *events)
1212
1212
 
1213
- def ping(self, **kwargs) -> ResponseT:
1213
+ def ping(self, **kwargs) -> Union[Awaitable[bool], bool]:
1214
1214
  """
1215
- Ping the Redis server
1215
+ Ping the Redis server to test connectivity.
1216
1216
 
1217
- For more information, see https://redis.io/commands/ping
1217
+ Sends a PING command to the Redis server and returns True if the server
1218
+ responds with "PONG".
1219
+
1220
+ This command is useful for:
1221
+ - Testing whether a connection is still alive
1222
+ - Verifying the server's ability to serve data
1223
+
1224
+ For more information on the underlying ping command see https://redis.io/commands/ping
1218
1225
  """
1219
1226
  return self.execute_command("PING", **kwargs)
1220
1227