Skip to content

Commit 96335e6

Browse files
authored
initial commit (#280)
1 parent 7de41dd commit 96335e6

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

arango/database.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
ServerRoleError,
5353
ServerRunTestsError,
5454
ServerShutdownError,
55+
ServerShutdownProgressError,
5556
ServerStatisticsError,
5657
ServerStatusError,
5758
ServerTimeError,
@@ -471,14 +472,21 @@ def response_handler(resp: Response) -> Json:
471472

472473
return self._execute(request, response_handler)
473474

474-
def shutdown(self) -> Result[bool]: # pragma: no cover
475+
def shutdown(self, soft: bool = False) -> Result[bool]: # pragma: no cover
475476
"""Initiate server shutdown sequence.
476477
478+
:param soft: If set to true, this initiates a soft shutdown. This is only
479+
available on Coordinators. When issued, the Coordinator tracks a number
480+
of ongoing operations, waits until all have finished, and then shuts
481+
itself down normally. It will still accept new operations.
482+
:type soft: bool
477483
:return: True if the server was shutdown successfully.
478484
:rtype: bool
479485
:raise arango.exceptions.ServerShutdownError: If shutdown fails.
480486
"""
481-
request = Request(method="delete", endpoint="/_admin/shutdown")
487+
request = Request(
488+
method="delete", endpoint="/_admin/shutdown", params={"soft": soft}
489+
)
482490

483491
def response_handler(resp: Response) -> bool:
484492
if not resp.is_success:
@@ -487,6 +495,26 @@ def response_handler(resp: Response) -> bool:
487495

488496
return self._execute(request, response_handler)
489497

498+
def shutdown_progress(self) -> Result[Json]: # pragma: no cover
499+
"""Query the soft shutdown progress. This call reports progress about a
500+
soft Coordinator shutdown (DELETE /_admin/shutdown?soft=true). This API
501+
is only available on Coordinators.
502+
503+
:return: Information about the shutdown progress.
504+
:rtype: dict
505+
:raise arango.exceptions.ServerShutdownError: If shutdown fails.
506+
"""
507+
request = Request(method="get", endpoint="/_admin/shutdown")
508+
509+
def response_handler(resp: Response) -> Json:
510+
if not resp.is_success:
511+
raise ServerShutdownProgressError(resp, request)
512+
513+
result: Json = resp.body
514+
return result
515+
516+
return self._execute(request, response_handler)
517+
490518
def run_tests(self, tests: Sequence[str]) -> Result[Json]: # pragma: no cover
491519
"""Run available unittests on the server.
492520

arango/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ class ServerShutdownError(ArangoServerError):
630630
"""Failed to initiate shutdown sequence."""
631631

632632

633+
class ServerShutdownProgressError(ArangoServerError):
634+
"""Failed to retrieve soft shutdown progress."""
635+
636+
633637
class ServerRunTestsError(ArangoServerError):
634638
"""Failed to execute server tests."""
635639

0 commit comments

Comments
 (0)