[][src]Struct tsunami::TsunamiBuilder

#[must_use]
pub struct TsunamiBuilder { /* fields omitted */ }

Use this to prepare and execute a new tsunami.

A tsunami consists of one or more MachineSetups that will be spawned as EC2 spot instances. See TsunamiBuilder#add_set) for how to construct a tsunami.

Methods

impl TsunamiBuilder[src]

pub fn add_set(&mut self, name: &str, number: u32, setup: MachineSetup)[src]

Add a new (named) machine setup template, and set how many instances of that type should be spawned as part of the tsunami.

let mut b = TsunamiBuilder::default();
b.add_set(
    "server",
    1,
    MachineSetup::new("m5.large", "ami-e18aa89b", |ssh| {
        ssh.cmd("yum install nginx").map(|out| {
            println!("{}", out);
        })
    }),
);
b.add_set(
    "client",
    10,
    MachineSetup::new("m5.large", "ami-e18aa89b", |ssh| {
        ssh.cmd("yum install wget").map(|out| {
            println!("{}", out);
        })
    }),
);

pub fn set_region(&mut self, region: Region)[src]

Set up the machines in a specific EC2 Region.

The default region is us-east-1. Available regions are listed here

pub fn set_availability_zone(&mut self, zone: &str)[src]

Set up the machines in a specific EC2 availability zone.

This controls the availability_zone field of the SpotPlacement struct (N.B.: even though the documentation claims that the parameter only affects spot fleets, it does appear to affect all spot instances).

pub fn no_clustering(&mut self)[src]

By default, all spawned instances are launched in a single Placement Group using the cluster policy. This ensures that all the instances are located in the same availability region, and in close proximity to one another.

This places some restrictions on the launched instances, and causes it to be more likely for placements to fail. Call this method to disable clustering. This will leave instance placing entirely up to ec2, which may choose to place your instances in disparate availability zones.

pub fn wait_limit(&mut self, t: Duration)[src]

Limit how long we should wait for instances to be available before giving up.

This includes both waiting for spot requests to be satisfied, and for SSH connections to be established. Defaults to no limit.

pub fn set_max_duration(&mut self, hours: u8)[src]

Set the maxium lifetime of spawned spot instances.

EC2 spot instances are normally subject to termination at any point. This library instead uses defined duration instances, which cost slightly more, but are never prematurely terminated. The lifetime of such instances must be declared in advance (1-6 hours), and can be changed with this method.

The default duration is 1 hour.

pub fn set_logger(&mut self, log: Logger)[src]

Set the logging target for this tsunami.

By default, logging is disabled (i.e., the default logger is slog::Discard).

pub fn use_term_logger(&mut self)[src]

Enable logging to terminal.

pub fn run<F, R>(self, f: F) -> Result<R, Error> where
    F: FnOnce(HashMap<String, Vec<Machine>>) -> Result<R, Error>, 
[src]

Spin up a tsunami batching the defined machine sets in this builder.

When all instances are up and running, the given closure will be called with a handle to all spawned hosts. When the closure exits, the instances are all terminated automatically.

This method uses the rusoto DefaultCredentialsProvider, which (primarily) uses standard AWS environtment variables for authentication. See also the underlying ChainProvider documentation.

let mut b = TsunamiBuilder::default();
// ...
b.run(|vms: HashMap<String, Vec<Machine>>| {
    println!("==> {}", vms["server"][0].private_ip);
    for c in &vms["client"] {
        println!(" -> {}", c.private_ip);
    }
    Ok(())
}).unwrap();

pub fn run_as<P, F, R>(self, provider: P, f: F) -> Result<R, Error> where
    P: ProvideAwsCredentials + Send + Sync + 'static,
    <P as ProvideAwsCredentials>::Future: Send,
    F: FnOnce(HashMap<String, Vec<Machine>>) -> Result<R, Error>, 
[src]

Spin up a tsunami batching the defined machine sets in this builder with a custom credentials provider.

When all instances are up and running, the given closure will be called with a handle to all spawned hosts. When the closure exits, the instances are all terminated automatically.

// https://github.com/rusoto/rusoto/blob/master/AWS-CREDENTIALS.md
let sts = rusoto_sts::StsClient::new(rusoto_core::Region::UsEast1);
let provider = rusoto_sts::StsAssumeRoleSessionCredentialsProvider::new(
    sts,
    "arn:aws:sts::1122334455:role/myrole".to_owned(),
    "session-name".to_owned(),
    None,
    None,
    None,
    None,
);

let mut b = TsunamiBuilder::default();
// ...
b.run_as(provider, |vms: HashMap<String, Vec<Machine>>| {
    println!("==> {}", vms["server"][0].private_ip);
    for c in &vms["client"] {
        println!(" -> {}", c.private_ip);
    }
    Ok(())
}).unwrap();

Trait Implementations

impl Default for TsunamiBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> Erased for T

impl<T> Same<T> for T

type Output = T

Should always be Self