Trait tsunami::Tsunami[][src]

pub trait Tsunami: Sealed {
    type MachineDescriptor: MachineSetup;
    fn spawn<'l, I>(
        &'l mut self,
        descriptors: I,
        max_wait: Option<Duration>
    ) -> Pin<Box<dyn Future<Output = Result<(), Report>> + Send + 'l>>
    where
        I: IntoIterator<Item = (String, Self::MachineDescriptor)> + Send + 'static,
        I: Debug,
        I::IntoIter: Send
;
fn connect_all<'l>(
        &'l self
    ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Machine<'l>>, Report>> + Send + 'l>>;
fn terminate_all(
        self
    ) -> Pin<Box<dyn Future<Output = Result<(), Report>> + Send>>; }

Use this trait to launch machines into providers.

Important: You must call terminate_all to shut down the instances once you are done. Otherwise, you may incur unexpected charges from the cloud provider.

This trait is sealed. If you want to implement support for a provider, see providers::Launcher.

Associated Types

type MachineDescriptor: MachineSetup[src]

A type describing a single instance to launch.

Loading content...

Required methods

fn spawn<'l, I>(
    &'l mut self,
    descriptors: I,
    max_wait: Option<Duration>
) -> Pin<Box<dyn Future<Output = Result<(), Report>> + Send + 'l>> where
    I: IntoIterator<Item = (String, Self::MachineDescriptor)> + Send + 'static,
    I: Debug,
    I::IntoIter: Send
[src]

Start up all the hosts.

The returned future will resolve when the instances are spawned into the provided launcher. SSH connections to each instance are accesssible via connect_all.

The argument descriptors is an iterator of machine nickname to descriptor. Duplicate nicknames will cause an error. To add many and auto-generate nicknames, see the helper function crate::make_multiple.

max_wait limits how long we should wait for instances to be available before giving up. Passing None implies no limit.

Example

#[tokio::main]
async fn main() -> Result<(), color_eyre::Report> {
    use tsunami::Tsunami;
    // make a launcher
    let mut aws: tsunami::providers::aws::Launcher<_> = Default::default();
    // spawn a host into the launcher
    aws.spawn(vec![(String::from("my_tsunami"), Default::default())], None).await?;
    // access the host via the launcher
    let vms = aws.connect_all().await?;
    // we're done! terminate the instance.
    aws.terminate_all().await?;
    Ok(())
}

fn connect_all<'l>(
    &'l self
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Machine<'l>>, Report>> + Send + 'l>>
[src]

Return connections to the Machines that spawn spawned.

fn terminate_all(
    self
) -> Pin<Box<dyn Future<Output = Result<(), Report>> + Send>>
[src]

Shut down all instances.

Loading content...

Implementors

impl<L: Launcher> Tsunami for L[src]

type MachineDescriptor = L::MachineDescriptor

Loading content...