Skip to content

Commit e5b605d

Browse files
committed
Update documentation
1 parent 20118b9 commit e5b605d

File tree

6 files changed

+112
-22
lines changed

6 files changed

+112
-22
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:target: https://badge.fury.io/py/python-arango
1515
:alt: Package Version
1616

17-
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6-blue.svg
17+
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6%2C%203.7-blue.svg
1818
:target: https://github.com/joowani/python-arango
1919
:alt: Python Versions
2020

arango/collection.py

+28-8
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,13 @@ def insert_many(self,
15921592
return_old=False):
15931593
"""Insert multiple documents.
15941594
1595-
If inserting a document fails, the exception object is placed in the
1596-
result list instead of document metadata.
1595+
.. note::
1596+
1597+
If inserting a document fails, the exception is not raised but
1598+
returned as an object in the result list. It is up to you to
1599+
inspect the list to determine which documents were inserted
1600+
successfully (returns document metadata) and which were not
1601+
(returns exception object).
15971602
15981603
:param documents: List of new documents to insert. If they contain the
15991604
"_key" or "_id" fields, the values are used as the keys of the new
@@ -1746,8 +1751,13 @@ def update_many(self,
17461751
silent=False):
17471752
"""Update multiple documents.
17481753
1749-
If updating a document fails, the exception object is placed in the
1750-
result list instead of document metadata.
1754+
.. note::
1755+
1756+
If updating a document fails, the exception is not raised but
1757+
returned as an object in the result list. It is up to you to
1758+
inspect the list to determine which documents were updated
1759+
successfully (returns document metadata) and which were not
1760+
(returns exception object).
17511761
17521762
:param documents: Partial or full documents with the updated values.
17531763
They must contain the "_id" or "_key" fields.
@@ -1953,8 +1963,13 @@ def replace_many(self,
19531963
silent=False):
19541964
"""Replace multiple documents.
19551965
1956-
If replacing a document fails, the exception object is placed in the
1957-
result list instead of document metadata.
1966+
.. note::
1967+
1968+
If replacing a document fails, the exception is not raised but
1969+
returned as an object in the result list. It is up to you to
1970+
inspect the list to determine which documents were replaced
1971+
successfully (returns document metadata) and which were not
1972+
(returns exception object).
19581973
19591974
:param documents: New documents to replace the old ones with. They must
19601975
contain the "_id" or "_key" fields. Edge documents must also have
@@ -2142,8 +2157,13 @@ def delete_many(self,
21422157
silent=False):
21432158
"""Delete multiple documents.
21442159
2145-
If deleting a document fails, the exception object is placed in the
2146-
result list instead of document metadata.
2160+
.. note::
2161+
2162+
If deleting a document fails, the exception is not raised but
2163+
returned as an object in the result list. It is up to you to
2164+
inspect the list to determine which documents were deleted
2165+
successfully (returns document metadata) and which were not
2166+
(returns exception object).
21472167
21482168
:param documents: Document IDs, keys or bodies. Document bodies must
21492169
contain the "_id" or "_key" fields.

docs/cluster.rst

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Clusters
2+
--------
3+
4+
Python-arango provides support for ArangoDB clusters. For more information on
5+
clusters, refer to `ArangoDB manual`_.
6+
7+
.. _ArangoDB manual: https://docs.arangodb.com
8+
9+
Coordinators
10+
============
11+
12+
To connect to multiple ArangoDB hosts (e.g. coordinators) you must provide
13+
either a list of host strings or a comma-separated string during client
14+
initialization.
15+
16+
**Example:**
17+
18+
.. testcode::
19+
20+
from arango import ArangoClient
21+
22+
# Single instance
23+
client = ArangoClient(hosts='http://localhost:8529')
24+
25+
# Multiple instances (option 1: list)
26+
client = ArangoClient(hosts=['http://host1:8529', 'http://host2:8529'])
27+
28+
# Multiple instances (option 2: comma-separated string)
29+
client = ArangoClient(hosts='http://host1:8529,http://host2:8529')
30+
31+
Load-Balancing
32+
==============
33+
34+
There are two load-balancing strategies available: "roundrobin" and "random"
35+
(defaults to "roundrobin" if not specified).
36+
37+
**Example:**
38+
39+
.. testcode::
40+
41+
from arango import ArangoClient
42+
43+
hosts = ['http://host1:8529', 'http://host2:8529']
44+
45+
# Round-robin
46+
client = ArangoClient(hosts=hosts, host_resolver='roundrobin')
47+
48+
# Random
49+
client = ArangoClient(hosts=hosts, host_resolver='random')
50+
51+
See :ref:`ArangoClient` for API specification.

docs/http.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ HTTP Clients
44
Python-arango lets you define your own HTTP client for sending requests to
55
ArangoDB server. The default implementation uses the requests_ library.
66

7-
Your HTTP client must inherit :class:`arango.http.HTTPClient` and implement its
8-
two abstract methods:
7+
Your HTTP client must inherit :class:`arango.http.HTTPClient` and implement the
8+
following abstract methods:
99

1010
* :func:`arango.http.HTTPClient.create_session`
1111
* :func:`arango.http.HTTPClient.send_request`
1212

13-
The **create_session** method must return a session object (called per host)
14-
which will be stored in python-arango client. The **send_request** method must
15-
use the session to send a HTTP request, and return a fully populated instance
16-
of :class:`arango.response.Response`.
13+
The **create_session** method must return a `requests.Session`_ instance per
14+
connected host (coordinator). The session objects are stored in the client.
15+
16+
The **send_request** method must use the session to send an HTTP request, and
17+
return a fully populated instance of :class:`arango.response.Response`.
1718

1819
For example, let's say your HTTP client needs:
1920

@@ -100,8 +101,7 @@ Then you would inject your client as follows:
100101
http_client=CustomHTTPClient()
101102
)
102103
103-
For more information on how to configure a ``requests.Session`` object, refer
104-
to `requests documentation`_.
104+
See `requests.Session`_ for more details on how to create and manage sessions.
105105

106106
.. _requests: https://github.com/requests/requests
107-
.. _requests documentation: http://docs.python-requests.org/en/master/user/advanced/#session-objects
107+
.. _requests.Session: http://docs.python-requests.org/en/master/user/advanced/#session-objects

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Contents
7474
errors
7575
logging
7676
http
77+
cluster
7778
serializer
7879
contributing
7980
specs

docs/threading.rst

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
Threading
2-
---------
1+
Multithreading
2+
--------------
3+
4+
There are a few things you should consider before using python-arango in a
5+
multithreaded (or multiprocess) architecture.
6+
7+
Stateful Objects
8+
================
39

410
Instances of the following classes are considered *stateful*, and should not be
5-
shared across multiple threads without locks in place:
11+
accessed across multiple threads without locks in place:
612

713
* :ref:`BatchDatabase` (see :doc:`batch`)
814
* :ref:`BatchJob` (see :doc:`batch`)
915
* :ref:`Cursor` (see :doc:`cursor`)
1016

11-
The rest of python-arango is safe to use in multi-threaded environments.
17+
18+
HTTP Sessions
19+
=============
20+
21+
When :ref:`ArangoClient` is initialized, a `requests.Session`_ instance is
22+
created per ArangoDB host connected. HTTP requests to a host are sent using
23+
only its corresponding session. For more information on how to override this
24+
behaviour, see :doc:`http`.
25+
26+
Note that a `requests.Session`_ object may not always be thread-safe. Always
27+
research your use case!
28+
29+
.. _requests.Session: http://docs.python-requests.org/en/master/user/advanced/#session-objects

0 commit comments

Comments
 (0)