Skip to content

Commit 9490914

Browse files
committed
Completed compression documentation
1 parent 619c5c4 commit 9490914

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

docs/compression.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Compression
2+
------------
3+
4+
The :class:`arangoasync.client.ArangoClient` lets you define the preferred compression policy for request and responses. By default
5+
compression is disabled. You can change this by passing the `compression` parameter when creating the client. You may use
6+
:class:`arangoasync.compression.DefaultCompressionManager` or a custom subclass of :class:`arangoasync.compression.CompressionManager`.
7+
8+
.. code-block:: python
9+
10+
from arangoasync import ArangoClient
11+
from arangoasync.compression import DefaultCompressionManager
12+
13+
client = ArangoClient(
14+
hosts="http://localhost:8529",
15+
compression=DefaultCompressionManager(),
16+
)
17+
18+
Furthermore, you can customize the request compression policy by defining the minimum size of the request body that
19+
should be compressed and the desired compression level. Or, in order to explicitly disable compression, you can set the
20+
threshold parameter to -1.
21+
22+
.. code-block:: python
23+
24+
from arangoasync import ArangoClient
25+
from arangoasync.compression import DefaultCompressionManager
26+
27+
# Disable request compression.
28+
client1 = ArangoClient(
29+
hosts="http://localhost:8529",
30+
compression=DefaultCompressionManager(threshold=-1),
31+
)
32+
33+
# Enable request compression with a minimum size of 2 KB and a compression level of 8.
34+
client2 = ArangoClient(
35+
hosts="http://localhost:8529",
36+
compression=DefaultCompressionManager(threshold=2048, level=8),
37+
)
38+
39+
You can set the `accept` parameter in order to inform the server that the client prefers compressed responses (in the form
40+
of an *Accept-Encoding* header). By default the `DefaultCompressionManager` is configured to accept responses compressed using
41+
the *deflate* algorithm. Note that the server may or may not honor this preference, depending on how it is
42+
configured. This can be controlled by setting the `--http.compress-response-threshold` option to a value greater than 0
43+
when starting the ArangoDB server.
44+
45+
.. code-block:: python
46+
47+
from arangoasync import ArangoClient
48+
from arangoasync.compression import AcceptEncoding, DefaultCompressionManager
49+
50+
# Accept compressed responses explicitly.
51+
client = ArangoClient(
52+
hosts="http://localhost:8529",
53+
compression=DefaultCompressionManager(accept=AcceptEncoding.DEFLATE),
54+
)
55+
56+
See the :class:`arangoasync.compression.CompressionManager` class for more details on how to customize the compression policy.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Contents
6464
:maxdepth: 1
6565

6666
cursor
67+
compression
6768
errors
6869
errno
6970

0 commit comments

Comments
 (0)