1
+ __all__ = [
2
+ "ApiExecutor" ,
3
+ "DefaultApiExecutor" ,
4
+ "NonAsyncExecutor" ,
5
+ "TransactionApiExecutor" ,
6
+ "AsyncApiExecutor" ,
7
+ ]
8
+
1
9
from typing import Callable , Optional , TypeVar
2
10
3
11
from arangoasync .connection import Connection
11
19
T = TypeVar ("T" )
12
20
13
21
14
- class DefaultApiExecutor :
15
- """Default API executor .
22
+ class ExecutorContext :
23
+ """Base class for API executors .
16
24
17
- Responsible for executing requests and handling responses .
25
+ Not to be exported publicly .
18
26
19
27
Args:
20
28
connection: HTTP connection.
@@ -27,10 +35,6 @@ def __init__(self, connection: Connection) -> None:
27
35
def connection (self ) -> Connection :
28
36
return self ._conn
29
37
30
- @property
31
- def context (self ) -> str :
32
- return "default"
33
-
34
38
@property
35
39
def db_name (self ) -> str :
36
40
return self ._conn .db_name
@@ -49,6 +53,23 @@ def serialize(self, data: Json) -> str:
49
53
def deserialize (self , data : bytes ) -> Json :
50
54
return self .deserializer .loads (data )
51
55
56
+
57
+ class DefaultApiExecutor (ExecutorContext ):
58
+ """Default API executor.
59
+
60
+ Responsible for executing requests and handling responses.
61
+
62
+ Args:
63
+ connection: HTTP connection.
64
+ """
65
+
66
+ def __init__ (self , connection : Connection ) -> None :
67
+ super ().__init__ (connection )
68
+
69
+ @property
70
+ def context (self ) -> str :
71
+ return "default"
72
+
52
73
async def execute (
53
74
self , request : Request , response_handler : Callable [[Response ], T ]
54
75
) -> T :
@@ -62,7 +83,7 @@ async def execute(
62
83
return response_handler (response )
63
84
64
85
65
- class TransactionApiExecutor (DefaultApiExecutor ):
86
+ class TransactionApiExecutor (ExecutorContext ):
66
87
"""Executes transaction API requests.
67
88
68
89
Args:
@@ -97,7 +118,7 @@ async def execute(
97
118
return response_handler (response )
98
119
99
120
100
- class AsyncApiExecutor (DefaultApiExecutor ):
121
+ class AsyncApiExecutor (ExecutorContext ):
101
122
"""Executes asynchronous API requests (jobs).
102
123
103
124
Args:
@@ -144,3 +165,4 @@ async def execute(
144
165
145
166
146
167
ApiExecutor = DefaultApiExecutor | TransactionApiExecutor | AsyncApiExecutor
168
+ NonAsyncExecutor = DefaultApiExecutor | TransactionApiExecutor
0 commit comments