use std::sync::Arc;
use net_sdk::dataforts::{publish_blob_ref, BlobAdapter, MeshBlobAdapter, Redex};
const ADAPTER_PROFILES: &[(&str, u64, usize, usize)] = &[
("primary", 1u64 << 40, 5, 3), ("cold", 512u64 << 30, 2, 18), ("replicated", 2u64 << 40, 11, 0), ("analytics", 768u64 << 30, 7, 5), ("backup", 4u64 << 40, 3, 0), ("ingest", 1u64 << 40, 14, 1), ("snapshot", 2u64 << 40, 4, 22), ("staging", 256u64 << 30, 8, 8), ("archive", 8u64 << 40, 1, 0), ];
pub async fn build_adapters(n: usize) -> Vec<Arc<MeshBlobAdapter>> {
let mut out = Vec::with_capacity(n);
for i in 0..n {
let (id, cap, stores, fetches) = ADAPTER_PROFILES
.get(i)
.copied()
.unwrap_or(*ADAPTER_PROFILES.last().unwrap());
out.push(install_one(id, cap, stores, fetches).await);
}
out
}
async fn install_one(
id: &str,
cap_bytes: u64,
stores: usize,
fetches: usize,
) -> Arc<MeshBlobAdapter> {
let redex = Arc::new(Redex::new());
let adapter = MeshBlobAdapter::new(id, redex).with_disk_capacity(cap_bytes);
let adapter = Arc::new(adapter);
let mut stored = Vec::with_capacity(stores);
for i in 0..stores {
let payload = format!("{id}/blob-{i:03}-demo-content").into_bytes();
match publish_blob_ref(adapter.as_ref(), format!("mesh://{id}/{i}"), &payload).await {
Ok(blob) => stored.push(blob),
Err(e) => {
eprintln!("[deck demo] dataforts seed publish failed on {id}/{i}: {e}");
}
}
}
if let Some(blob) = stored.first() {
for _ in 0..fetches {
let _ = BlobAdapter::fetch(adapter.as_ref(), blob).await;
}
}
adapter
}