use crate::bridge::envelope::PhysicalPlan;
use crate::control::state::SharedState;
use crate::types::{DatabaseId, TenantId, TraceId, VShardId};
use nodedb_physical::physical_plan::MetaOp;
pub async fn dispatch_unregister_collection(
state: &SharedState,
tenant_id: u64,
name: &str,
purge_lsn: u64,
) {
let tenant = TenantId::new(tenant_id);
let vshard = VShardId::from_collection_in_database(DatabaseId::DEFAULT, name);
let plan = PhysicalPlan::Meta(MetaOp::UnregisterCollection {
tenant_id,
name: name.to_string(),
purge_lsn,
});
if let Err(e) = crate::control::server::dispatch_utils::dispatch_to_data_plane(
state,
tenant,
vshard,
plan,
TraceId::ZERO,
)
.await
{
tracing::warn!(
%name,
tenant = tenant_id,
error = %e,
"failed to dispatch UnregisterCollection to Data Plane (non-fatal — retry on next GC pass)"
);
}
}