feat: add distribution release and recovery controls

This commit is contained in:
巫凤萍
2026-08-12 11:12:23 +08:00
parent ddad4b7659
commit 7ef150e08b
16 changed files with 717 additions and 33 deletions

View File

@@ -155,6 +155,23 @@ export class DatabaseClient {
connection.release();
}
}
async transaction<T>(operation: (database: DatabaseClient) => Promise<T>) {
const pool = getPool();
const connection = await pool.getConnection();
try {
await connection.beginTransaction();
const transaction = new DatabaseClient(connection);
const result = await operation(transaction);
await connection.commit();
return result;
} catch (error) {
await connection.rollback();
throw error;
} finally {
connection.release();
}
}
}
declare global {