mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-09-02 09:39:37 +00:00
feat(db): add backend shutdown hook for graceful runtime shutdown
Add Database::shutdown() with a default no-op implementation for backward compatibility. Implement libSQL shutdown via flush_replicator(), treating SyncNotSupported as non-fatal. Implement Postgres shutdown by closing the pool.
This commit is contained in:
@@ -326,6 +326,18 @@ impl Database for LibSqlBackend {
|
||||
libsql_migrations::run_incremental(&conn).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn shutdown(&self) -> Result<(), DatabaseError> {
|
||||
match self.db.flush_replicator().await {
|
||||
Ok(Some(frame_no)) => {
|
||||
tracing::debug!("libSQL replicator flushed at frame {}", frame_no);
|
||||
Ok(())
|
||||
}
|
||||
Ok(None) => Ok(()),
|
||||
Err(libsql::Error::SyncNotSupported(_)) => Ok(()),
|
||||
Err(error) => Err(DatabaseError::from(error)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Row conversion helpers ====================
|
||||
|
||||
Reference in New Issue
Block a user