diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2022-06-01 16:46:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 16:46:21 +0300 |
commit | 3081a32b3852276999bb250655e4dfe2c87c654c (patch) | |
tree | 50a0417796dd6fc8531167b69dc0aa0ff179b495 /redis/commands/core.py | |
parent | fa0be7671de6be85f859cbb57a31531b2482c9e1 (diff) | |
download | redis-py-3081a32b3852276999bb250655e4dfe2c87c654c.tar.gz |
SHUTDOWN - add support for the new NOW, FORCE and ABORT modifiers (#2150)
* add support for NOW, FORCE and ABORT modifiers
* linters
* test
* linters
* test params
* fix tests
Co-authored-by: Chayim <chayim@users.noreply.github.com>
Diffstat (limited to 'redis/commands/core.py')
-rw-r--r-- | redis/commands/core.py | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/redis/commands/core.py b/redis/commands/core.py index ab246a7..a337d4f 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -1153,12 +1153,25 @@ class ManagementCommands(CommandsProtocol): """ return self.execute_command("SAVE", **kwargs) - def shutdown(self, save: bool = False, nosave: bool = False, **kwargs) -> None: + def shutdown( + self, + save: bool = False, + nosave: bool = False, + now: bool = False, + force: bool = False, + abort: bool = False, + **kwargs, + ) -> None: """Shutdown the Redis server. If Redis has persistence configured, - data will be flushed before shutdown. If the "save" option is set, - a data flush will be attempted even if there is no persistence - configured. If the "nosave" option is set, no data flush will be - attempted. The "save" and "nosave" options cannot both be set. + data will be flushed before shutdown. + It is possible to specify modifiers to alter the behavior of the command: + ``save`` will force a DB saving operation even if no save points are configured. + ``nosave`` will prevent a DB saving operation even if one or more save points + are configured. + ``now`` skips waiting for lagging replicas, i.e. it bypasses the first step in + the shutdown sequence. + ``force`` ignores any errors that would normally prevent the server from exiting + ``abort`` cancels an ongoing shutdown and cannot be combined with other flags. For more information see https://redis.io/commands/shutdown """ @@ -1169,6 +1182,12 @@ class ManagementCommands(CommandsProtocol): args.append("SAVE") if nosave: args.append("NOSAVE") + if now: + args.append("NOW") + if force: + args.append("FORCE") + if abort: + args.append("ABORT") try: self.execute_command(*args, **kwargs) except ConnectionError: @@ -1279,7 +1298,13 @@ class AsyncManagementCommands(ManagementCommands): return super().memory_help(**kwargs) async def shutdown( - self, save: bool = False, nosave: bool = False, **kwargs + self, + save: bool = False, + nosave: bool = False, + now: bool = False, + force: bool = False, + abort: bool = False, + **kwargs, ) -> None: """Shutdown the Redis server. If Redis has persistence configured, data will be flushed before shutdown. If the "save" option is set, @@ -1296,6 +1321,12 @@ class AsyncManagementCommands(ManagementCommands): args.append("SAVE") if nosave: args.append("NOSAVE") + if now: + args.append("NOW") + if force: + args.append("FORCE") + if abort: + args.append("ABORT") try: await self.execute_command(*args, **kwargs) except ConnectionError: |