Skip to content

Commit f05756c

Browse files
committed
Moving "list_transactions" into Database class
1 parent c45a95b commit f05756c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

arangoasync/database.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,26 @@ def response_handler(resp: Response) -> Json:
10791079

10801080
return await self._executor.execute(request, response_handler)
10811081

1082+
async def list_transactions(self) -> Result[Jsons]:
1083+
"""List all currently running stream transactions.
1084+
1085+
Returns:
1086+
list: List of transactions, with each transaction containing
1087+
an "id" and a "state" field.
1088+
1089+
Raises:
1090+
TransactionListError: If the operation fails on the server side.
1091+
"""
1092+
request = Request(method=Method.GET, endpoint="/_api/transaction")
1093+
1094+
def response_handler(resp: Response) -> Jsons:
1095+
if not resp.is_success:
1096+
raise TransactionListError(resp, request)
1097+
result: Json = self.deserializer.loads(resp.raw_body)
1098+
return cast(Jsons, result["transactions"])
1099+
1100+
return await self._executor.execute(request, response_handler)
1101+
10821102

10831103
class StandardDatabase(Database):
10841104
"""Standard database API wrapper.
@@ -1188,26 +1208,6 @@ def fetch_transaction(self, transaction_id: str) -> "TransactionDatabase":
11881208
"""
11891209
return TransactionDatabase(self.connection, transaction_id)
11901210

1191-
async def list_transactions(self) -> Result[Jsons]:
1192-
"""List all currently running stream transactions.
1193-
1194-
Returns:
1195-
list: List of transactions, with each transaction containing
1196-
an "id" and a "state" field.
1197-
1198-
Raises:
1199-
TransactionListError: If the operation fails on the server side.
1200-
"""
1201-
request = Request(method=Method.GET, endpoint="/_api/transaction")
1202-
1203-
def response_handler(resp: Response) -> Jsons:
1204-
if not resp.is_success:
1205-
raise TransactionListError(resp, request)
1206-
result: Json = self.deserializer.loads(resp.raw_body)
1207-
return cast(Jsons, result["transactions"])
1208-
1209-
return await self._executor.execute(request, response_handler)
1210-
12111211

12121212
class TransactionDatabase(Database):
12131213
"""Database API tailored specifically for

0 commit comments

Comments
 (0)