15
15
16
16
class HTTPClient (ABC ): # pragma: no cover
17
17
"""Abstract base class for HTTP clients.
18
+
18
19
Custom HTTP clients should inherit from this class.
20
+
21
+ Example:
22
+ .. code-block:: python
23
+
24
+ class MyCustomHTTPClient(HTTPClient):
25
+ def create_session(self, host):
26
+ pass
27
+ async def send_request(self, session, request):
28
+ pass
19
29
"""
20
30
21
31
@abstractmethod
22
32
def create_session (self , host : str ) -> Any :
23
33
"""Return a new session given the base host URL.
24
34
25
- This method must be overridden by the user.
35
+ Note:
36
+ This method must be overridden by the user.
37
+
38
+ Args:
39
+ host (str): ArangoDB host URL.
26
40
27
- :param host: ArangoDB host URL.
28
- :type host: str
29
- :returns: Requests session object.
30
- :rtype: Any
41
+ Returns:
42
+ Requests session object.
31
43
"""
32
44
raise NotImplementedError
33
45
@@ -39,37 +51,36 @@ async def send_request(
39
51
) -> Response :
40
52
"""Send an HTTP request.
41
53
42
- This method must be overridden by the user.
54
+ Note:
55
+ This method must be overridden by the user.
43
56
44
- :param session: Session object.
45
- :type session: Any
46
- :param request: HTTP request.
47
- :type request: arangoasync.request.Request
48
- :returns: HTTP response.
49
- :rtype: arangoasync. response.Response
57
+ Args:
58
+ session ( Any): Client session object.
59
+ request (Request) : HTTP request.
60
+
61
+ Returns:
62
+ Response: HTTP response.
50
63
"""
51
64
raise NotImplementedError
52
65
53
66
54
67
class AioHTTPClient (HTTPClient ):
55
- """HTTP client implemented on top of [aiohttp](https://docs.aiohttp.org/en/stable/).
56
-
57
- :param connector: Supports connection pooling.
58
- By default, 100 simultaneous connections are supported, with a 60-second timeout
59
- for connection reusing after release.
60
- :type connector: aiohttp.BaseConnector | None
61
- :param timeout: Timeout settings.
62
- 300s total timeout by default for a complete request/response operation.
63
- :type timeout: aiohttp.ClientTimeout | None
64
- :param read_bufsize: Size of read buffer (64KB default).
65
- :type read_bufsize: int
66
- :param auth: HTTP authentication helper.
67
- Should be used for specifying authorization data in client API.
68
- :type auth: aiohttp.BasicAuth | None
69
- :param compression_threshold: Will compress requests to the server if
70
- the size of the request body (in bytes) is at least the value of this
71
- option.
72
- :type compression_threshold: int
68
+ """HTTP client implemented on top of aiohttp_.
69
+
70
+ Args:
71
+ connector (aiohttp.BaseConnector | None): Supports connection pooling.
72
+ By default, 100 simultaneous connections are supported, with a 60-second
73
+ timeout for connection reusing after release.
74
+ timeout (aiohttp.ClientTimeout | None): Client timeout settings.
75
+ 300s total timeout by default for a complete request/response operation.
76
+ read_bufsize (int): Size of read buffer (64KB default).
77
+ auth (aiohttp.BasicAuth | None): HTTP authentication helper.
78
+ Should be used for specifying authorization data in client API.
79
+ compression_threshold (int): Will compress requests to the server if the size
80
+ of the request body (in bytes) is at least the value of this option.
81
+
82
+ .. _aiohttp:
83
+ https://docs.aiohttp.org/en/stable/
73
84
"""
74
85
75
86
def __init__ (
@@ -95,11 +106,12 @@ def __init__(
95
106
def create_session (self , host : str ) -> ClientSession :
96
107
"""Return a new session given the base host URL.
97
108
98
- :param host: ArangoDB host URL. Typically, the address and port of a coordinator
99
- (e.g. "http://127.0.0.1:8529").
100
- :type host: str
101
- :returns: Session object.
102
- :rtype: aiohttp.ClientSession
109
+ Args:
110
+ host (str): ArangoDB host URL. Must not include any paths. Typically, this
111
+ is the address and port of a coordinator (e.g. "http://127.0.0.1:8529").
112
+
113
+ Returns:
114
+ aiohttp.ClientSession: Session object, used to send future requests.
103
115
"""
104
116
return ClientSession (
105
117
base_url = host ,
@@ -116,12 +128,12 @@ async def send_request(
116
128
) -> Response :
117
129
"""Send an HTTP request.
118
130
119
- :param session: Session object.
120
- :type session: aiohttp.ClientSession
121
- :param request: HTTP request.
122
- :type request: arangoasync.request.Request
123
- :returns: HTTP response.
124
- :rtype: arangoasync. response.Response
131
+ Args:
132
+ session ( aiohttp.ClientSession): Session object used to make the request.
133
+ request (Request) : HTTP request.
134
+
135
+ Returns:
136
+ Response: HTTP response.
125
137
"""
126
138
method = request .method
127
139
endpoint = request .endpoint
0 commit comments