fmt
This commit is contained in:
parent
d715d94b6d
commit
a7b588da97
14 changed files with 48 additions and 48 deletions
|
|
@ -14,7 +14,7 @@ use sqlx::{ConnectOptions, Connection, sqlite::SqliteConnectOptions, types::chro
|
|||
|
||||
pub mod models;
|
||||
|
||||
/// Sentinel error indicating the SQLite database is busy (SQLITE_BUSY).
|
||||
/// Sentinel error indicating the `SQLite` database is busy (`SQLITE_BUSY`).
|
||||
/// Handlers can downcast to this to return 429 instead of 500.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("Database is busy")]
|
||||
|
|
@ -76,11 +76,11 @@ pub struct Database {
|
|||
config: DatabaseConfig,
|
||||
broadcasts: Broadcasts,
|
||||
connection_pools: Arc<Mutex<HashMap<VaultId, Arc<VaultPool>>>>,
|
||||
/// Per-vault write serialization. SQLite allows only one writer at a
|
||||
/// Per-vault write serialization. `SQLite` allows only one writer at a
|
||||
/// time; `BEGIN IMMEDIATE` on a second connection blocks until the first
|
||||
/// commits (up to `busy_timeout`). Under concurrent load the blocked
|
||||
/// connections consume the pool, starving even read-only requests.
|
||||
/// This mutex moves the wait from the SQLite layer (where it holds a
|
||||
/// This mutex moves the wait from the `SQLite` layer (where it holds a
|
||||
/// pool connection) to the Tokio layer (where it holds nothing).
|
||||
write_locks: Arc<Mutex<HashMap<VaultId, Arc<tokio::sync::Mutex<()>>>>>,
|
||||
/// Monotonic epoch for lock-free `last_accessed_ms` timestamps
|
||||
|
|
@ -768,9 +768,6 @@ impl Database {
|
|||
vault_update_id: version.vault_update_id,
|
||||
document_id: version.document_id,
|
||||
relative_path: version.relative_path.clone(),
|
||||
updated_date: version.updated_date,
|
||||
user_id: version.user_id.clone(),
|
||||
device_id: version.device_id.clone(),
|
||||
},
|
||||
)),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -82,11 +82,7 @@ impl Broadcasts {
|
|||
/// Synchronous: safe to invoke from a handler between `commit()` and
|
||||
/// function return without worrying about task cancellation dropping
|
||||
/// the broadcast mid-flight. Failures are logged, never propagated.
|
||||
pub fn send_document_update(
|
||||
&self,
|
||||
vault: VaultId,
|
||||
document: WebSocketServerMessageWithOrigin,
|
||||
) {
|
||||
pub fn send_document_update(&self, vault: VaultId, document: WebSocketServerMessageWithOrigin) {
|
||||
let mut tx_map = self
|
||||
.tx
|
||||
.lock()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||
use ts_rs::TS;
|
||||
|
||||
use crate::app_state::database::models::{
|
||||
DeviceId, DocumentId, DocumentVersionWithoutContent, UserId, VaultUpdateId,
|
||||
DeviceId, DocumentId, DocumentVersionWithoutContent, VaultUpdateId,
|
||||
};
|
||||
|
||||
#[derive(TS, Deserialize, Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ pub fn get_authenticated_handshake(
|
|||
let user = auth(state, handshake.token.trim(), vault_id)?;
|
||||
Ok(AuthenticatedWebSocketHandshake { handshake, user })
|
||||
}
|
||||
WebSocketClientMessage::CursorPositions(_) => Err(
|
||||
unauthenticated_error(anyhow::anyhow!("Expected a handshake message")),
|
||||
),
|
||||
WebSocketClientMessage::CursorPositions(_) => Err(unauthenticated_error(
|
||||
anyhow::anyhow!("Expected a handshake message"),
|
||||
)),
|
||||
}
|
||||
} else {
|
||||
Err(unauthenticated_error(anyhow::anyhow!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue