Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
apetenchea committed Jun 8, 2023
1 parent e15a0b8 commit 045b4f1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ database natively supporting documents, graphs and search.

## Requirements

- ArangoDB version 3.7+
- ArangoDB version 3.9+
- Python version 3.8+

## Installation
Expand Down
12 changes: 6 additions & 6 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To ensure PEP8_ compliance, run flake8_:
.. code-block:: bash
~$ pip install flake8
~$ git clone https://github.com/joowani/python-arango.git
~$ git clone https://github.com/ArangoDB-Community/python-arango.git
~$ cd python-arango
~$ flake8
Expand All @@ -57,7 +57,7 @@ To run the test suite (use your own host, port and root password):
.. code-block:: bash
~$ pip install pytest
~$ git clone https://github.com/joowani/python-arango.git
~$ git clone https://github.com/ArangoDB-Community/python-arango.git
~$ cd python-arango
~$ py.test --complete --host=127.0.0.1 --port=8529 --passwd=passwd
Expand All @@ -66,7 +66,7 @@ To run the test suite with coverage report:
.. code-block:: bash
~$ pip install coverage pytest pytest-cov
~$ git clone https://github.com/joowani/python-arango.git
~$ git clone https://github.com/ArangoDB-Community/python-arango.git
~$ cd python-arango
~$ py.test --complete --host=127.0.0.1 --port=8529 --passwd=passwd --cov=kq
Expand All @@ -82,9 +82,9 @@ Sphinx_. To build an HTML version on your local machine:
.. code-block:: bash
~$ pip install sphinx sphinx_rtd_theme
~$ git clone https://github.com/joowani/python-arango.git
~$ cd python-arango/docs
~$ sphinx-build . build # Open build/index.html in a browser
~$ git clone https://github.com/ArangoDB-Community/python-arango.git
~$ cd python-arango
~$ python -m sphinx -b html -W docs docs/_build/ # Open build/index.html in a browser
As always, thank you for your contribution!

Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Welcome to the documentation for **python-arango**, a Python driver for ArangoDB
Requirements
=============

- ArangoDB version 3.7+
- ArangoDB version 3.9+
- Python version 3.8+

Installation
Expand Down Expand Up @@ -38,6 +38,7 @@ Contents
cursor
async
batch
overload
transaction
admin
user
Expand Down
58 changes: 58 additions & 0 deletions docs/overload.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Overload API Execution
----------------------
:ref:`OverloadControlDatabase` is designed to handle time-bound requests. It allows setting a maximum server-side
queuing time for client requests via the *max_queue_time_seconds* parameter. If the server's queueing time for a
request surpasses this defined limit, the request will be rejected. This mechanism provides you with more control over
request handling, enabling your application to react effectively to potential server overloads.

Additionally, the response from ArangoDB will always include the most recent request queuing/dequeuing time from the
server's perspective. This can be accessed via the :attr:`~.OverloadControlDatabase.last_queue_time` property.

**Example:**

.. testcode::

from arango import errno
from arango import ArangoClient
from arango.exceptions import OverloadControlExecutorError

# Initialize the ArangoDB client.
client = ArangoClient()

# Connect to "test" database as root user.
db = client.db('test', username='root', password='passwd')

# Begin controlled execution.
controlled_db = db.begin_controlled_execution(max_queue_time_seconds=7.5)

# All requests surpassing the specified limit will be rejected.
controlled_aql = controlled_db.aql
controlled_col = controlled_db.collection('students')

# On API execution, the last_queue_time property gets updated.
controlled_col.insert({'_key': 'Neal'})

# Retrieve the last recorded queue time.
assert controlled_db.last_queue_time >= 0

try:
controlled_aql.execute('RETURN 100000')
except OverloadControlExecutorError as err:
assert err.http_code == errno.HTTP_PRECONDITION_FAILED
assert err.error_code == errno.QUEUE_TIME_REQUIREMENT_VIOLATED

# Retrieve the maximum allowed queue time.
assert controlled_db.max_queue_time == 7.5

# Adjust the maximum allowed queue time.
controlled_db.adjust_max_queue_time(0.0001)

# Disable the maximum allowed queue time.
controlled_db.adjust_max_queue_time(None)

.. note::
Setting *max_queue_time_seconds* to 0 or a non-numeric value will cause ArangoDB to ignore the header.

See :ref:`OverloadControlDatabase` for API specification.
See the `official documentation <https://www.arangodb.com/docs/stable/http/general.html#overload-control>`_ for
details on ArangoDB's overload control options.
9 changes: 9 additions & 0 deletions docs/specs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ HTTPClient
.. autoclass:: arango.http.HTTPClient
:members:

.. _OverloadControlDatabase:

OverloadControlDatabase
=======================

.. autoclass:: arango.database.OverloadControlDatabase
:inherited-members:
:members:

.. _Pregel:

Pregel
Expand Down

0 comments on commit 045b4f1

Please sign in to comment.