Configuration class for maintenance notifications handling behaviour. Notifications are received through push notifications. This class defines how the Redis client should react to different push notifications such as node moving, migrations, etc. in a Redis cluster.
| 610 | |
| 611 | |
| 612 | class MaintNotificationsConfig: |
| 613 | """ |
| 614 | Configuration class for maintenance notifications handling behaviour. Notifications are received through |
| 615 | push notifications. |
| 616 | |
| 617 | This class defines how the Redis client should react to different push notifications |
| 618 | such as node moving, migrations, etc. in a Redis cluster. |
| 619 | |
| 620 | """ |
| 621 | |
| 622 | def __init__( |
| 623 | self, |
| 624 | enabled: Union[bool, Literal["auto"]] = "auto", |
| 625 | proactive_reconnect: bool = True, |
| 626 | relaxed_timeout: Optional[Number] = 10, |
| 627 | endpoint_type: Optional[EndpointType] = None, |
| 628 | ): |
| 629 | """ |
| 630 | Initialize a new MaintNotificationsConfig. |
| 631 | |
| 632 | Args: |
| 633 | enabled (bool | "auto"): Controls maintenance notifications handling behavior. |
| 634 | - True: The CLIENT MAINT_NOTIFICATIONS command must succeed during connection setup, |
| 635 | otherwise a ResponseError is raised. |
| 636 | - "auto": The CLIENT MAINT_NOTIFICATIONS command is attempted but failures are |
| 637 | gracefully handled - a warning is logged and normal operation continues. |
| 638 | - False: Maintenance notifications are completely disabled. |
| 639 | Defaults to "auto". |
| 640 | proactive_reconnect (bool): Whether to proactively reconnect when a node is replaced. |
| 641 | Defaults to True. |
| 642 | relaxed_timeout (Number): The relaxed timeout to use for the connection during maintenance. |
| 643 | If -1 is provided - the relaxed timeout is disabled. Defaults to 20. |
| 644 | endpoint_type (Optional[EndpointType]): Override for the endpoint type to use in CLIENT MAINT_NOTIFICATIONS. |
| 645 | If None, the endpoint type will be automatically determined based on the host and TLS configuration. |
| 646 | Defaults to None. |
| 647 | |
| 648 | Raises: |
| 649 | ValueError: If endpoint_type is provided but is not a valid endpoint type. |
| 650 | """ |
| 651 | self.enabled = enabled |
| 652 | self.relaxed_timeout = relaxed_timeout |
| 653 | self.proactive_reconnect = proactive_reconnect |
| 654 | self.endpoint_type = endpoint_type |
| 655 | |
| 656 | def __repr__(self) -> str: |
| 657 | return ( |
| 658 | f"{self.__class__.__name__}(" |
| 659 | f"enabled={self.enabled}, " |
| 660 | f"proactive_reconnect={self.proactive_reconnect}, " |
| 661 | f"relaxed_timeout={self.relaxed_timeout}, " |
| 662 | f"endpoint_type={self.endpoint_type!r}" |
| 663 | f")" |
| 664 | ) |
| 665 | |
| 666 | def is_relaxed_timeouts_enabled(self) -> bool: |
| 667 | """ |
| 668 | Check if the relaxed_timeout is enabled. The '-1' value is used to disable the relaxed_timeout. |
| 669 | If relaxed_timeout is set to None, it will make the operation blocking |
no outgoing calls