Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_new_aircraft() { | |
let ac312 = PassengerAircraft::new("ac312_toronto_newyork_1700"); | |
assert_eq!(ac312.id(), "ac312_toronto_newyork_1700"); | |
} |
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
// Coordinator is playing a mediator role which ensure the only place to | |
pub trait Coordinator { | |
fn arrival(&mut self, aircraft_id: &str) -> bool; | |
fn gate_available(&mut self) -> Option<i8>; | |
fn departure(&mut self, aircraft_id: &str); | |
} | |
impl Coordinator for Airport { | |
fn arrival(&mut self, aircraft_id: &str) -> bool { | |
/* |
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
pub struct PassengerAircraft { | |
id: String, | |
} | |
impl PassengerAircraft { | |
pub fn new(id: impl Into<String>) -> Self { | |
Self { | |
id: id.into(), | |
} | |
} |
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
pub struct Airport { | |
name: String, | |
aircrafts: HashMap<String, Box<dyn Aircraft>>, | |
aircraft_on_gate: HashMap<i8, String>, | |
aircraft_queue: VecDeque<String>, | |
gates: HashMap<i8, bool>, | |
} | |
impl Airport { | |
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
name: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
BUILD_HOME: /home/runner/work/bot/bot |
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
# build | |
cargo build --release --target=x86_64-unknown-linux-musl | |
# move to the bootstrap name | |
cp target/x86_64-unknown-linux-musl/release/rstvb bootstrap | |
# zip as lambda.zip | |
zip lambda.zip bootstrap |
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
[[bin]] | |
name = "bootstrap" | |
path = "src/bootstrap.rs" | |
[[bin]] | |
name = "main" | |
path = "src/main.rs" |
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
#[tokio::main] | |
async fn main() -> Result<(), Error> { | |
dotenv().ok(); | |
// The runtime logging can be enabled here by initializing `tracing` with `tracing-subscriber` | |
// While `tracing` is used internally, `log` can be used as well if preferred. | |
tracing_subscriber::fmt() | |
.with_max_level(tracing::Level::INFO) | |
// disabling time is handy because CloudWatch will add the ingestion time. | |
.without_time() |
NewerOlder