Skip to main content

espresso_api/v1/
database.rs

1//! V1 database API.
2//!
3//! Diagnostic. `DatabaseService` mirrors this shape on v2, where field numbers are frozen, so
4//! the fields here are no longer free to change.
5
6use async_trait::async_trait;
7use serde::{Deserialize, Serialize};
8
9/// Database table size information.
10#[derive(Serialize, Deserialize, Clone, Debug)]
11pub struct TableSize {
12    pub table_name: String,
13    pub row_count: i64,
14    pub total_size_bytes: Option<i64>,
15}
16
17/// Status of a single deferred background migration.
18#[derive(Serialize, Deserialize, Clone, Debug)]
19pub struct MigrationStatus {
20    pub name: String,
21    pub started_at: chrono::DateTime<chrono::Utc>,
22    pub completed_at: Option<chrono::DateTime<chrono::Utc>>,
23    pub last_offset: Option<i64>,
24}
25
26#[async_trait]
27pub trait DatabaseApi {
28    async fn get_table_sizes(&self) -> anyhow::Result<Vec<TableSize>>;
29    async fn get_migration_status(&self) -> anyhow::Result<Vec<MigrationStatus>>;
30}