mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 06:44:56 -04:00
Move DB pool and helper functions into dedicated Database class
This commit is contained in:
parent
ddbbfc9512
commit
756d4942f5
62 changed files with 2377 additions and 2295 deletions
|
@ -77,7 +77,7 @@ class TransactionStore(SQLBaseStore):
|
|||
this transaction or a 2-tuple of (int, dict)
|
||||
"""
|
||||
|
||||
return self.runInteraction(
|
||||
return self.db.runInteraction(
|
||||
"get_received_txn_response",
|
||||
self._get_received_txn_response,
|
||||
transaction_id,
|
||||
|
@ -85,7 +85,7 @@ class TransactionStore(SQLBaseStore):
|
|||
)
|
||||
|
||||
def _get_received_txn_response(self, txn, transaction_id, origin):
|
||||
result = self.simple_select_one_txn(
|
||||
result = self.db.simple_select_one_txn(
|
||||
txn,
|
||||
table="received_transactions",
|
||||
keyvalues={"transaction_id": transaction_id, "origin": origin},
|
||||
|
@ -119,7 +119,7 @@ class TransactionStore(SQLBaseStore):
|
|||
response_json (str)
|
||||
"""
|
||||
|
||||
return self.simple_insert(
|
||||
return self.db.simple_insert(
|
||||
table="received_transactions",
|
||||
values={
|
||||
"transaction_id": transaction_id,
|
||||
|
@ -148,7 +148,7 @@ class TransactionStore(SQLBaseStore):
|
|||
if result is not SENTINEL:
|
||||
return result
|
||||
|
||||
result = yield self.runInteraction(
|
||||
result = yield self.db.runInteraction(
|
||||
"get_destination_retry_timings",
|
||||
self._get_destination_retry_timings,
|
||||
destination,
|
||||
|
@ -160,7 +160,7 @@ class TransactionStore(SQLBaseStore):
|
|||
return result
|
||||
|
||||
def _get_destination_retry_timings(self, txn, destination):
|
||||
result = self.simple_select_one_txn(
|
||||
result = self.db.simple_select_one_txn(
|
||||
txn,
|
||||
table="destinations",
|
||||
keyvalues={"destination": destination},
|
||||
|
@ -187,7 +187,7 @@ class TransactionStore(SQLBaseStore):
|
|||
"""
|
||||
|
||||
self._destination_retry_cache.pop(destination, None)
|
||||
return self.runInteraction(
|
||||
return self.db.runInteraction(
|
||||
"set_destination_retry_timings",
|
||||
self._set_destination_retry_timings,
|
||||
destination,
|
||||
|
@ -227,7 +227,7 @@ class TransactionStore(SQLBaseStore):
|
|||
# We need to be careful here as the data may have changed from under us
|
||||
# due to a worker setting the timings.
|
||||
|
||||
prev_row = self.simple_select_one_txn(
|
||||
prev_row = self.db.simple_select_one_txn(
|
||||
txn,
|
||||
table="destinations",
|
||||
keyvalues={"destination": destination},
|
||||
|
@ -236,7 +236,7 @@ class TransactionStore(SQLBaseStore):
|
|||
)
|
||||
|
||||
if not prev_row:
|
||||
self.simple_insert_txn(
|
||||
self.db.simple_insert_txn(
|
||||
txn,
|
||||
table="destinations",
|
||||
values={
|
||||
|
@ -247,7 +247,7 @@ class TransactionStore(SQLBaseStore):
|
|||
},
|
||||
)
|
||||
elif retry_interval == 0 or prev_row["retry_interval"] < retry_interval:
|
||||
self.simple_update_one_txn(
|
||||
self.db.simple_update_one_txn(
|
||||
txn,
|
||||
"destinations",
|
||||
keyvalues={"destination": destination},
|
||||
|
@ -270,4 +270,6 @@ class TransactionStore(SQLBaseStore):
|
|||
def _cleanup_transactions_txn(txn):
|
||||
txn.execute("DELETE FROM received_transactions WHERE ts < ?", (month_ago,))
|
||||
|
||||
return self.runInteraction("_cleanup_transactions", _cleanup_transactions_txn)
|
||||
return self.db.runInteraction(
|
||||
"_cleanup_transactions", _cleanup_transactions_txn
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue