mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-26 23:55:15 -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
|
@ -133,7 +133,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
A Deferred which resolves to a list of ApplicationServices, which
|
||||
may be empty.
|
||||
"""
|
||||
results = yield self.simple_select_list(
|
||||
results = yield self.db.simple_select_list(
|
||||
"application_services_state", dict(state=state), ["as_id"]
|
||||
)
|
||||
# NB: This assumes this class is linked with ApplicationServiceStore
|
||||
|
@ -155,7 +155,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
Returns:
|
||||
A Deferred which resolves to ApplicationServiceState.
|
||||
"""
|
||||
result = yield self.simple_select_one(
|
||||
result = yield self.db.simple_select_one(
|
||||
"application_services_state",
|
||||
dict(as_id=service.id),
|
||||
["state"],
|
||||
|
@ -175,7 +175,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
Returns:
|
||||
A Deferred which resolves when the state was set successfully.
|
||||
"""
|
||||
return self.simple_upsert(
|
||||
return self.db.simple_upsert(
|
||||
"application_services_state", dict(as_id=service.id), dict(state=state)
|
||||
)
|
||||
|
||||
|
@ -216,7 +216,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
)
|
||||
return AppServiceTransaction(service=service, id=new_txn_id, events=events)
|
||||
|
||||
return self.runInteraction("create_appservice_txn", _create_appservice_txn)
|
||||
return self.db.runInteraction("create_appservice_txn", _create_appservice_txn)
|
||||
|
||||
def complete_appservice_txn(self, txn_id, service):
|
||||
"""Completes an application service transaction.
|
||||
|
@ -249,7 +249,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
)
|
||||
|
||||
# Set current txn_id for AS to 'txn_id'
|
||||
self.simple_upsert_txn(
|
||||
self.db.simple_upsert_txn(
|
||||
txn,
|
||||
"application_services_state",
|
||||
dict(as_id=service.id),
|
||||
|
@ -257,11 +257,13 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
)
|
||||
|
||||
# Delete txn
|
||||
self.simple_delete_txn(
|
||||
self.db.simple_delete_txn(
|
||||
txn, "application_services_txns", dict(txn_id=txn_id, as_id=service.id)
|
||||
)
|
||||
|
||||
return self.runInteraction("complete_appservice_txn", _complete_appservice_txn)
|
||||
return self.db.runInteraction(
|
||||
"complete_appservice_txn", _complete_appservice_txn
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_oldest_unsent_txn(self, service):
|
||||
|
@ -283,7 +285,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
" ORDER BY txn_id ASC LIMIT 1",
|
||||
(service.id,),
|
||||
)
|
||||
rows = self.cursor_to_dict(txn)
|
||||
rows = self.db.cursor_to_dict(txn)
|
||||
if not rows:
|
||||
return None
|
||||
|
||||
|
@ -291,7 +293,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
|
||||
return entry
|
||||
|
||||
entry = yield self.runInteraction(
|
||||
entry = yield self.db.runInteraction(
|
||||
"get_oldest_unsent_appservice_txn", _get_oldest_unsent_txn
|
||||
)
|
||||
|
||||
|
@ -321,7 +323,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
"UPDATE appservice_stream_position SET stream_ordering = ?", (pos,)
|
||||
)
|
||||
|
||||
return self.runInteraction(
|
||||
return self.db.runInteraction(
|
||||
"set_appservice_last_pos", set_appservice_last_pos_txn
|
||||
)
|
||||
|
||||
|
@ -350,7 +352,7 @@ class ApplicationServiceTransactionWorkerStore(
|
|||
|
||||
return upper_bound, [row[1] for row in rows]
|
||||
|
||||
upper_bound, event_ids = yield self.runInteraction(
|
||||
upper_bound, event_ids = yield self.db.runInteraction(
|
||||
"get_new_events_for_appservice", get_new_events_for_appservice_txn
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue