📡 WADM Status Receiver Example
This folder contains a WebAssembly component that makes use of:
- The 
wasmcloud:wadm/handlerWIT contract - The 
wadm-providerCapability Provider 
📦 Dependencies
cargo(part of the Rust toolchain) for building this projectwashfor building and running the components and wasmCloud hosts
👟 Quickstart
As with all other examples, you can get started quickly by using the Wasmcloud SHell (wash).
Since wash supports declarative deployments (powered by [Wasmcloud Application Deployment Manager (wadm)][wadm]), you can get started quickly using the provided manifests:
Build this component
wash buildThis will create a folder called build which contains wadm_status_receiver_s.wasm.
[!NOTE] If you're using a local build of the provider (using
file://...inwadm.yaml) this is a good time to ensure you've built the [provider archivepar.gz][par] for your provider.
Start a wasmCloud host with WADM
wash upDeploy the status receiver application
First, deploy our status receiver component that will listen for updates:
wash app deploy local.wadm.yamlDeploy the example application to monitor
Now deploy the example application that our receiver will monitor:
wash app deploy example.wadm.yamlYou should start seeing status updates in the logs as the example application deploys and its status changes.
To see everything running in the lattice:
wash get inventoryTo test status changes, you can:
- Undeploy the example application:
console
wash app undeploy rust-hello-world - Redeploy it:
console
wash app deploy rust-hello-world 
Each of these actions will generate status updates that our receiver will log.
⌨️ Code guide
impl Guest for StatusReceiver {
    fn handle_status_update(msg: StatusUpdate) -> Result<(), String> {
        wasi::logging::logging::log(
            wasi::logging::logging::Level::Info,
            "wadm-status",
            &format!(
                "Application '{}' v{} - Status: {:?}",
                msg.app, msg.status.version, msg.status.info.status_type
            ),
        );
        wasi::logging::logging::log(
            wasi::logging::logging::Level::Info,
            "wadm-status",
            &format!("Components found: {}", msg.status.components.len()),
        );
        for component in msg.status.components {
            wasi::logging::logging::log(
                wasi::logging::logging::Level::Info,
                "wadm-status",
                &format!(
                    "Component '{}' - Status: {:?}",
                    component.name, component.info.status_type
                ),
            );
        }
        Ok(())
    }
}