-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.rs
More file actions
51 lines (44 loc) · 1.61 KB
/
quickstart.rs
File metadata and controls
51 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Quick Start Example
//!
//! This example demonstrates the basic usage of the Orpheon Protocol.
use orpheon_sdk::prelude::*;
#[tokio::main]
async fn main() -> Result<(), OrpheonError> {
// Connect to an Orpheon node
let client = OrpheonClient::connect("http://localhost:3000").await?;
// 1. Define what you want
let intent = Intent::builder()
.kind("provision_gpu_cluster")
.resource_limit("count", 8.0)
.sla("type", 100, "H100") // Simplified for example
.budget(Budget::usd(100.0))
.minimize("cost", 0.6)
.maximize("speed", 0.4)
.build()?;
// 2. Submit intent and subscribe to updates
let mut plan_stream = client.submit(intent).await?;
println!("🚀 Intent submitted, waiting for updates...");
// 3. Process events
while let Some(event) = plan_stream.next().await {
match event {
Event::Negotiating { estimated_cost, .. } => {
println!("💬 Negotiating: estimated cost ${:.2}", estimated_cost);
}
Event::Executing { step_name, progress, .. } => {
println!("⚙️ Executing: {} ({:.0}%)", step_name, progress * 100.0);
}
Event::Complete { artifact_id } => {
println!("✅ Done! Artifact ID: {}", artifact_id);
break;
}
Event::StatusUpdate { status, .. } => {
println!("📊 Status: {}", status);
}
Event::Error { message } => {
println!("❌ Error: {}", message);
break;
}
}
}
Ok(())
}