pub struct Client { /* private fields */ }
Expand description
A client for interacting with the lattice
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
host: &str,
credsfile: Option<PathBuf>,
call_timeout: Duration,
namespace: Option<String>,
) -> Self
pub fn new( host: &str, credsfile: Option<PathBuf>, call_timeout: Duration, namespace: Option<String>, ) -> Self
Creates a new lattice client, connecting to the NATS server at the given host with an optional set of credentials (JWT auth)
pub fn with_connection( nc: Connection, call_timeout: Duration, namespace: Option<String>, ) -> Self
Sourcepub fn get_hosts(&self) -> Result<Vec<HostProfile>, Box<dyn Error>>
pub fn get_hosts(&self) -> Result<Vec<HostProfile>, Box<dyn Error>>
Retrieves the list of all hosts running within the lattice. If it takes a host longer than the call timeout period to reply to the probe, it will not be included in the list of hosts.
Sourcepub fn get_bindings(
&self,
) -> Result<HashMap<String, Vec<Binding>>, Box<dyn Error>>
pub fn get_bindings( &self, ) -> Result<HashMap<String, Vec<Binding>>, Box<dyn Error>>
Retrieves a list of all bindings from actors to capabilities within the lattice (provided the host responds to the probe within the client timeout period)
Sourcepub fn get_actors(
&self,
) -> Result<HashMap<String, Vec<Claims<Actor>>>, Box<dyn Error>>
pub fn get_actors( &self, ) -> Result<HashMap<String, Vec<Claims<Actor>>>, Box<dyn Error>>
Retrieves the list of all actors currently running within the lattice (as discovered within the client timeout period)
Sourcepub fn get_capabilities(
&self,
) -> Result<HashMap<String, Vec<HostedCapability>>, Box<dyn Error>>
pub fn get_capabilities( &self, ) -> Result<HashMap<String, Vec<HostedCapability>>, Box<dyn Error>>
Retrieves the list of all capabilities within the lattice (discovery limited by the client timeout period)
Sourcepub fn watch_events(
&self,
sender: Sender<BusEvent>,
) -> Result<(), Box<dyn Error>>
pub fn watch_events( &self, sender: Sender<BusEvent>, ) -> Result<(), Box<dyn Error>>
Watches the lattice for bus events. This will create a subscription in a background thread, so callers are responsible for ensuring their process remains alive however long is appropriate. Pass the sender half of a channel to receive the events
Sourcepub fn perform_actor_launch_auction(
&self,
actor_id: &str,
constraints: HashMap<String, String>,
) -> Result<Vec<LaunchAuctionResponse>, Box<dyn Error>>
pub fn perform_actor_launch_auction( &self, actor_id: &str, constraints: HashMap<String, String>, ) -> Result<Vec<LaunchAuctionResponse>, Box<dyn Error>>
Performs an auction among all hosts on the lattice, requesting that the given actor be launched (loaded+started) on a suitable host as described by the set of constraints. Only hosts that believe they can launch the actor will reply. In other words, there will be no negative responses in the result vector, only a list of suitable hosts. The actor to be launched is identified by an OCI registry reference
Sourcepub fn perform_provider_launch_auction(
&self,
provider_ref: &str,
binding_name: &str,
constraints: HashMap<String, String>,
) -> Result<Vec<ProviderAuctionResponse>, Box<dyn Error>>
pub fn perform_provider_launch_auction( &self, provider_ref: &str, binding_name: &str, constraints: HashMap<String, String>, ) -> Result<Vec<ProviderAuctionResponse>, Box<dyn Error>>
Performs an auction among all hosts on the lattice, requesting that the given capability provider (indicated by OCI image reference) be loaded/started. Hosts that believe they can host the provider given the constraints will respond to the auction
Sourcepub fn launch_provider_on_host(
&self,
provider_ref: &str,
host_id: &str,
binding_name: &str,
) -> Result<ProviderLaunchAck, Box<dyn Error>>
pub fn launch_provider_on_host( &self, provider_ref: &str, host_id: &str, binding_name: &str, ) -> Result<ProviderLaunchAck, Box<dyn Error>>
After collecting the results of a provider launch auction, a “winner” from among the hosts can be selected and told to launch the given provider. The provider’s bytes will be retrieved from the OCI registry. This function does not confirm successful launch, only receipt of the launch request.
Sourcepub fn launch_actor_on_host(
&self,
actor_id: &str,
host_id: &str,
) -> Result<LaunchAck, Box<dyn Error>>
pub fn launch_actor_on_host( &self, actor_id: &str, host_id: &str, ) -> Result<LaunchAck, Box<dyn Error>>
After collecting the results of a launch auction, a “winner” from among the hosts can be selected and told to launch a given actor. Note that the actor’s bytes will be retrieved from the OCI registry. This function does not confirm successful launch, only that the target host acknowledged the request to launch.
Sourcepub fn stop_actor_on_host(
&self,
actor_id: &str,
host_id: &str,
) -> Result<(), Box<dyn Error>>
pub fn stop_actor_on_host( &self, actor_id: &str, host_id: &str, ) -> Result<(), Box<dyn Error>>
Sends a command to the specified host telling it to terminate an actor. The success of this command indicates a successful publication, and not necessarily a successful remote actor termination. Monitor the lattice events to see if the actor was successfully terminated