-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the internals haven't been implemented yet, but I want an interface to do TDD off of while developing
- Loading branch information
1 parent
0682c58
commit 83290a1
Showing
6 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
use std::sync::Mutex; | ||
|
||
#[macro_use] | ||
extern crate lazy_static; | ||
#[macro_use(c)] | ||
extern crate cute; | ||
use futures::future::try_join_all; | ||
use rand::{thread_rng, Rng}; | ||
use turbolift::kubernetes::K8s; | ||
use turbolift::on; | ||
|
||
lazy_static! { | ||
static ref K8S: Mutex<K8s> = Mutex::new(K8s::new()); | ||
} | ||
|
||
#[on(K8S)] | ||
fn square(u: u64) -> u64 { | ||
u * u | ||
} | ||
|
||
fn random_numbers() -> Vec<u64> { | ||
let mut pseud = thread_rng(); | ||
c![pseud.gen_range(0, 1000), for _i in 1..10] | ||
} | ||
|
||
fn main() { | ||
println!("Hello, world!"); | ||
let input = random_numbers(); | ||
let futures = c![square(*int), for int in &input]; | ||
let output = async_std::task::block_on(try_join_all(futures)).unwrap(); | ||
println!("input: {:?}\noutput: {:?}", input, output); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let input = random_numbers(); | ||
let futures = c![square(*int), for int in &input]; | ||
let output = async_std::task::block_on(try_join_all(futures)).unwrap(); | ||
assert_eq!( | ||
output, | ||
input.into_iter().map(|x| x * x).collect::<Vec<u64>>() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
#[cfg(feature = "distributed")] | ||
pub use async_std; | ||
#[cfg(feature = "distributed")] | ||
pub use cached; | ||
#[cfg(feature = "distributed")] | ||
pub use chrono; | ||
|
||
pub use actix_web; | ||
#[cfg(feature = "service")] | ||
pub use serde_json; | ||
|
||
pub use actix_web; | ||
pub use cached; | ||
|
||
pub use distributed_platform::{DistributionPlatform, DistributionResult}; | ||
pub use turbolift_internals::*; | ||
pub use turbolift_macros::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters