Struct tsunami::TsunamiBuilder [−][src]
#[must_use]pub struct TsunamiBuilder { /* fields omitted */ }
Use this to prepare and execute a new tsunami.
A tsunami consists of one or more MachineSetup
s that will be
spawned as EC2 spot instances. See
TsunamiBuilder#add_set
) for how to construct a
tsunami.
Methods
impl TsunamiBuilder
[src]
impl TsunamiBuilder
pub fn add_set(&mut self, name: &str, number: u32, setup: MachineSetup)
[src]
pub fn add_set(&mut self, name: &str, number: u32, setup: MachineSetup)
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]
pub fn set_region(&mut self, region: Region)
Set up the machines in a specific EC2
Region
.
The default region is us-east-1. Available regions are listed here
pub fn no_clustering(&mut self)
[src]
pub fn no_clustering(&mut self)
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]
pub fn wait_limit(&mut self, t: Duration)
Limit how long we should wait for spot requests to be satisfied before giving up.
pub fn set_max_duration(&mut self, hours: u8)
[src]
pub fn set_max_duration(&mut self, hours: u8)
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]
pub fn set_logger(&mut self, log: Logger)
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]
pub fn use_term_logger(&mut self)
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]
pub fn run<F, R>(self, f: F) -> Result<R, Error> where
F: FnOnce(HashMap<String, Vec<Machine>>) -> Result<R, Error>,
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
EnvironmentProvider
,
which uses standard AWS environtment
variables for
authentication.
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,
F: FnOnce(HashMap<String, Vec<Machine>>) -> Result<R, Error>,
[src]
pub fn run_as<P, F, R>(self, provider: P, f: F) -> Result<R, Error> where
P: ProvideAwsCredentials,
F: FnOnce(HashMap<String, Vec<Machine>>) -> Result<R, Error>,
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::default_tls_client().unwrap(), rusoto_core::EnvironmentProvider, 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]
impl Default for TsunamiBuilder
Auto Trait Implementations
impl !Send for TsunamiBuilder
impl !Send for TsunamiBuilder
impl Sync for TsunamiBuilder
impl Sync for TsunamiBuilder