Skip to main content

snapshot/
snapshot.rs

1use spacedb_console::*;
2fn main() {
3    let obs = Observations {
4        homes: vec![
5            HomeObs { id: "home-ny-1".into(), region: "us-east".into(), online: true },
6            HomeObs { id: "home-ny-2".into(), region: "us-east".into(), online: true },
7            HomeObs { id: "home-sf-1".into(), region: "us-west".into(), online: false },
8        ],
9        shards: vec![
10            ShardObs { id: "profiles-0".into(), collection: "profiles".into(), reachable_replicas: 3, target_replicas: 3, durable_floor: 1, size_bytes: 4 << 30 },
11            ShardObs { id: "photos-7".into(), collection: "photos".into(), reachable_replicas: 2, target_replicas: 3, durable_floor: 1, size_bytes: 60 << 30 },
12            ShardObs { id: "ledger-2".into(), collection: "ledger".into(), reachable_replicas: 1, target_replicas: 3, durable_floor: 1, size_bytes: 1 << 30 },
13        ],
14        strong: vec![
15            StrongObs { collection: "usernames".into(), members_online: 3, members_total: 3 },
16            StrongObs { collection: "seats".into(), members_online: 1, members_total: 3 },
17        ],
18        lags: vec![ LagObs { collection: "photos".into(), lag_ops: 340, region: Some("us-west".into()) } ],
19        capabilities: vec![
20            CapabilityObs { bearer: "did:mata:alice".into(), scope: "profiles".into(), ops: "rw".into(), expiry: Some(1_700_003_600), budget_micro_mata: None, revoked: false },
21            CapabilityObs { bearer: "did:agent:assistant".into(), scope: "profiles".into(), ops: "rc".into(), expiry: Some(1_702_592_000), budget_micro_mata: Some(1_000_000), revoked: false },
22        ],
23        audit: vec![
24            AuditObs { actor: "did:agent:assistant".into(), action: "retrieve".into(), at: 1_700_000_000, allowed: true },
25            AuditObs { actor: "did:agent:assistant".into(), action: "write".into(), at: 1_700_000_050, allowed: false },
26        ],
27        settled: vec![
28            SettledObs { host_did: "home-ny-1".into(), settles_to_did: "alice".into(), resource: Resource::Storage, micro_mata: 4_200_000 },
29            SettledObs { host_did: "home-ny-2".into(), settles_to_did: "alice".into(), resource: Resource::Compute, micro_mata: 380_000 },
30            SettledObs { host_did: "home-ny-1".into(), settles_to_did: "bob".into(), resource: Resource::Transit, micro_mata: 95_000 },
31        ],
32        budgets: vec![
33            AgentBudgetObs { agent: "did:agent:assistant".into(), remaining: 40_000, limit: 1_000_000 },
34        ],
35        unsettled_claims: 12,
36    };
37    print!("{}", Dashboard::assemble(&obs, &Config::at(1_700_000_100)).render_text());
38}