chore: Refactor transaction_ids -> transactions

This commit is contained in:
timedout
2026-02-23 17:44:35 +00:00
parent d311b87579
commit 558262dd1f
7 changed files with 15 additions and 16 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ pub(super) async fn incoming_federation(&self) -> Result {
let mut msg = format!(
"Handling {} incoming PDUs across {} active transactions:\n",
map.len(),
self.services.transaction_ids.txn_active_handle_count()
self.services.transactions.txn_active_handle_count()
);
for (r, (e, i)) in map.iter() {
let elapsed = i.elapsed();
+2 -2
View File
@@ -50,7 +50,7 @@ pub(crate) async fn send_message_event_route(
// Check if this is a new transaction id
if let Ok(response) = services
.transaction_ids
.transactions
.get_client_txn(sender_user, sender_device, &body.txn_id)
.await
{
@@ -92,7 +92,7 @@ pub(crate) async fn send_message_event_route(
)
.await?;
services.transaction_ids.add_client_txnid(
services.transactions.add_client_txnid(
sender_user,
sender_device,
&body.txn_id,
+2 -2
View File
@@ -26,7 +26,7 @@ pub(crate) async fn send_event_to_device_route(
// Check if this is a new transaction id
if services
.transaction_ids
.transactions
.get_client_txn(sender_user, sender_device, &body.txn_id)
.await
.is_ok()
@@ -104,7 +104,7 @@ pub(crate) async fn send_event_to_device_route(
// Save transaction id with empty data
services
.transaction_ids
.transactions
.add_client_txnid(sender_user, sender_device, &body.txn_id, &[]);
Ok(send_event_to_device::v3::Response {})
+6 -6
View File
@@ -43,7 +43,7 @@ use ruma::{
to_device::DeviceIdOrAllDevices,
uint,
};
use service::transaction_ids::{
use service::transactions::{
FederationTxnState, TransactionError, TxnKey, WrappedTransactionResponse,
};
use tokio::sync::watch::{Receiver, Sender};
@@ -84,7 +84,7 @@ pub(crate) async fn send_transaction_message_route(
// Atomically check cache, join active, or start new transaction
match services
.transaction_ids
.transactions
.get_or_start_federation_txn(txn_key.clone())?
{
| FederationTxnState::Cached(response) => {
@@ -195,7 +195,7 @@ async fn process_inbound_transaction(
};
services
.transaction_ids
.transactions
.finish_federation_txn(txn_key, sender, response);
}
@@ -211,7 +211,7 @@ fn fail_federation_txn(
debug!("Transaction failed: {err}");
// Remove from active state so the transaction can be retried
services.transaction_ids.remove_federation_txn(txn_key);
services.transactions.remove_federation_txn(txn_key);
// Send the error to any waiters
if let Err(e) = sender.send(Some(Err(err))) {
@@ -628,7 +628,7 @@ async fn handle_edu_direct_to_device(
// Check if this is a new transaction id
if services
.transaction_ids
.transactions
.get_client_txn(sender, None, message_id)
.await
.is_ok()
@@ -648,7 +648,7 @@ async fn handle_edu_direct_to_device(
// Save transaction id with empty data
services
.transaction_ids
.transactions
.add_client_txnid(sender, None, message_id, &[]);
}
+1 -1
View File
@@ -31,7 +31,7 @@ pub mod rooms;
pub mod sending;
pub mod server_keys;
pub mod sync;
pub mod transaction_ids;
pub mod transactions;
pub mod uiaa;
pub mod users;
+3 -3
View File
@@ -14,7 +14,7 @@ use crate::{
media, moderation, presence, pusher, registration_tokens, resolver, rooms, sending,
server_keys,
service::{self, Args, Map, Service},
sync, transaction_ids, uiaa, users,
sync, transactions, uiaa, users,
};
pub struct Services {
@@ -37,7 +37,7 @@ pub struct Services {
pub sending: Arc<sending::Service>,
pub server_keys: Arc<server_keys::Service>,
pub sync: Arc<sync::Service>,
pub transaction_ids: Arc<transaction_ids::Service>,
pub transactions: Arc<transactions::Service>,
pub uiaa: Arc<uiaa::Service>,
pub users: Arc<users::Service>,
pub moderation: Arc<moderation::Service>,
@@ -110,7 +110,7 @@ impl Services {
sending: build!(sending::Service),
server_keys: build!(server_keys::Service),
sync: build!(sync::Service),
transaction_ids: build!(transaction_ids::Service),
transactions: build!(transactions::Service),
uiaa: build!(uiaa::Service),
users: build!(users::Service),
moderation: build!(moderation::Service),
@@ -11,7 +11,6 @@ use std::{
use async_trait::async_trait;
use conduwuit::{Error, Result, SyncRwLock, debug_warn, warn};
use database::{Handle, Map};
use futures::SinkExt;
use ruma::{
DeviceId, OwnedServerName, OwnedTransactionId, TransactionId, UserId,
api::{