Struct wasmcloud_control_interface::Client [−][src]
pub struct Client { /* fields omitted */ }
Expand description
Lattice control interface client
Implementations
Creates a new lattice control interface client
Queries the lattice for all responsive hosts, waiting for the full period specified by timeout.
pub async fn get_host_inventory(
&self,
host_id: &str
) -> Result<HostInventory, Box<dyn Error + Send + Sync>>
pub async fn get_host_inventory(
&self,
host_id: &str
) -> Result<HostInventory, Box<dyn Error + Send + Sync>>
Retrieves the contents of a running host
Retrieves the full set of all cached claims in the lattice by getting a response from the first host that answers this query
Performs an actor auction within the lattice, publishing a set of constraints and the metadata for the actor in question. This will always wait for the full period specified by duration, and then return the set of gathered results. It is then up to the client to choose from among the “auction winners” to issue the appropriate command to start an actor. Clients cannot assume that auctions will always return at least one result.
Performs a provider auction within the lattice, publishing a set of constraints and the metadata for the provider in question. This will always wait for the full period specified by duration, and then return the set of gathered results. It is then up to the client to choose from among the “auction winners” and issue the appropriate command to start a provider. Clients cannot assume that auctions will always return at least one result.
Sends a request to the given host to start a given actor by its OCI reference. This returns an acknowledgement of receipt of the command, not a confirmation that the actor started. An acknowledgement will either indicate some form of validation failure, or, if no failure occurs, the receipt of the command. To avoid blocking consumers, wasmCloud hosts will acknowledge the start actor command prior to fetching the actor’s OCI bytes. If a client needs deterministic results as to whether the actor completed its startup process, the client will have to monitor the appropriate event in the control event stream
Publishes the link advertisement message to the lattice that is published when code invokes the set_link
function on a Host
struct instance. No confirmation or acknowledgement is available for this operation
because it is publish-only.
Publishes a request to remove a link definition to the lattice.
Publishes a request to retrieve all current link definitions.
Issue a command to a host instructing that it replace an existing actor (indicated by its public key) with a new actor indicated by an OCI image reference. The host will acknowledge this request as soon as it verifies that the target actor is running. This acknowledgement occurs before the new bytes are downloaded. Live-updating an actor can take a long time and control clients cannot block waiting for a reply that could come several seconds later. If you need to verify that the actor has been updated, you will want to set up a listener for the appropriate PublishedEvent which will be published on the control events channel in JSON
Issues a command to a host to start a provider with a given OCI reference using the specified link name (or “default” if none is specified). The target wasmCloud host will acknowledge the receipt of this command before downloading the provider’s bytes from the OCI registry, indicating either a validation failure or success. If a client needs deterministic guarantees that the provider has completed its startup process, such a client needs to monitor the control event stream for the appropriate event
Issues a command to a host to stop a provider for the given OCI reference, link name, and contract ID. The target wasmCloud host will acknowledge the receipt of this command, and will not supply a discrete confirmation that a provider has terminated. For that kind of information, the client must also monitor the control event stream
Issues a command to a host to stop an actor for the given OCI reference. The target wasmCloud host will acknowledge the receipt of this command, and will not supply a discrete confirmation that the actor has terminated. For that kind of information, the client must also monitor the control event stream
Issues a command to a specific host to perform a graceful termination. The target host will acknowledge receipt of the command before it attempts a shutdown. To deterministically verify that the host is down, a client should monitor for the “host stopped” event or passively detect the host down by way of a lack of heartbeat receipts
Returns the receiver end of a channel that subscribes to the lattice control event stream.
Any Event
s that are published after this channel is created
will be added to the receiver channel’s buffer, which can be observed or handled if needed.
See the example for how you could use this receiver to handle events.
Example
use wasmcloud_control_interface::Client;
async {
let nc = nats::asynk::connect("0.0.0.0:4222").await.unwrap();
let client = Client::new(nc, None, std::time::Duration::from_millis(1000));
let receiver = client.events_receiver().await.unwrap();
std::thread::spawn(move || loop {
if let Ok(evt) = receiver.recv() {
println!("Event received: {:?}", evt);
} else {
// channel is closed
break;
}
});
// perform other operations on client
client.get_host_inventory("NAEXHW...").await.unwrap();
};
Once you’re finished with the event receiver, be sure to call drop
with the receiver
as an argument. This closes the channel and will prevent the sender from endlessly
sending messages into the channel buffer.
Example
use wasmcloud_control_interface::Client;
async {
let nc = nats::asynk::connect("0.0.0.0:4222").await.unwrap();
let client = Client::new(nc, None, std::time::Duration::from_millis(1000));
let receiver = client.events_receiver().await.unwrap();
std::thread::spawn(move || {
if let Ok(evt) = receiver.recv() {
println!("Event received: {:?}", evt);
// We received our one event, now close the channel
drop(receiver);
} else {
// channel is closed
return;
}
});
};