Source commit: be1f654ae8de7d5eeb2005b4e1a05bf1ebf3124f Public tree identity: sha256:ab53679496be4be7d1e02bc00723072774d1a3f87e10cc56558a752f28f6abb1
33 lines
1,006 B
Rust
33 lines
1,006 B
Rust
use std::error::Error;
|
|
|
|
use futures_executor::block_on;
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
let handle = block_on(
|
|
clusterflux::spawn::task_with_arg(41_i32, |_| -> i32 {
|
|
panic!("product-mode spawn invoked its local Rust closure")
|
|
})
|
|
.task_id("task_add_one")
|
|
.name("SDK product Wasmtime task")
|
|
.env(clusterflux::env!("linux"))
|
|
.start(),
|
|
)?;
|
|
let task_spec = handle
|
|
.task_spec()
|
|
.cloned()
|
|
.ok_or("CLUSTERFLUX_SDK_COORDINATOR did not enable product runtime")?;
|
|
let virtual_thread_id = handle.virtual_thread_id();
|
|
let result = block_on(handle.join())?;
|
|
|
|
println!(
|
|
"{}",
|
|
serde_json::to_string(&serde_json::json!({
|
|
"kind": "clusterflux-sdk-product-runtime",
|
|
"virtual_thread_id": virtual_thread_id,
|
|
"task_spec": task_spec,
|
|
"remote_result": result,
|
|
"local_function_invoked_by_spawn": false,
|
|
}))?
|
|
);
|
|
Ok(())
|
|
}
|