use std::time::Duration;
use bytes::Bytes;
use crate::bridge::physical_plan::{MetaOp, PhysicalPlan};
use crate::control::server::pgwire::ddl::sync_dispatch;
use crate::control::state::SharedState;
use crate::types::TenantId;
use nodedb_types::NodeDbError;
pub async fn run(
state: &SharedState,
tenant_id: TenantId,
timeout: Duration,
) -> Result<Bytes, NodeDbError> {
let plan = PhysicalPlan::Meta(MetaOp::CreateTenantSnapshot {
tenant_id: tenant_id.as_u64(),
});
let raw = sync_dispatch::dispatch_async(state, tenant_id, "__system", plan, timeout)
.await
.map_err(|e| {
NodeDbError::move_tenant_snapshot_failed(tenant_id.as_u64().to_string(), format!("{e}"))
})?;
Ok(Bytes::from(raw))
}
pub fn temp_key(tenant_id: TenantId) -> String {
format!("_move_tenant_snapshot_{}", tenant_id.as_u64())
}
pub async fn delete_temp(_state: &SharedState, _key: &str) -> Result<(), NodeDbError> {
Ok(())
}