1+ __all__ = [
2+ "ApiExecutor" ,
3+ "DefaultApiExecutor" ,
4+ "NonAsyncExecutor" ,
5+ "TransactionApiExecutor" ,
6+ "AsyncApiExecutor" ,
7+ ]
8+
19from typing import Callable , Optional , TypeVar
210
311from arangoasync .connection import Connection
1119T = TypeVar ("T" )
1220
1321
14- class DefaultApiExecutor :
15- """Default API executor .
22+ class ExecutorContext :
23+ """Base class for API executors .
1624
17- Responsible for executing requests and handling responses .
25+ Not to be exported publicly .
1826
1927 Args:
2028 connection: HTTP connection.
@@ -27,10 +35,6 @@ def __init__(self, connection: Connection) -> None:
2735 def connection (self ) -> Connection :
2836 return self ._conn
2937
30- @property
31- def context (self ) -> str :
32- return "default"
33-
3438 @property
3539 def db_name (self ) -> str :
3640 return self ._conn .db_name
@@ -49,6 +53,23 @@ def serialize(self, data: Json) -> str:
4953 def deserialize (self , data : bytes ) -> Json :
5054 return self .deserializer .loads (data )
5155
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+
5273 async def execute (
5374 self , request : Request , response_handler : Callable [[Response ], T ]
5475 ) -> T :
@@ -62,7 +83,7 @@ async def execute(
6283 return response_handler (response )
6384
6485
65- class TransactionApiExecutor (DefaultApiExecutor ):
86+ class TransactionApiExecutor (ExecutorContext ):
6687 """Executes transaction API requests.
6788
6889 Args:
@@ -97,7 +118,7 @@ async def execute(
97118 return response_handler (response )
98119
99120
100- class AsyncApiExecutor (DefaultApiExecutor ):
121+ class AsyncApiExecutor (ExecutorContext ):
101122 """Executes asynchronous API requests (jobs).
102123
103124 Args:
@@ -144,3 +165,4 @@ async def execute(
144165
145166
146167ApiExecutor = DefaultApiExecutor | TransactionApiExecutor | AsyncApiExecutor
168+ NonAsyncExecutor = DefaultApiExecutor | TransactionApiExecutor
0 commit comments