#![deny(warnings, missing_debug_implementations)]
#![allow(dead_code, clippy::new_without_default)]
pub mod annotations;
pub mod config;
pub mod current;
pub mod future;
pub mod hint;
pub mod runtime;
pub mod scheduler;
pub mod sync_types;
pub mod thread_support;
pub use config::{
Config, ContinuationFunctionBehavior, FailurePersistence, MaxSteps, UngracefulShutdownConfig,
UNGRACEFUL_SHUTDOWN_CONFIG,
};
pub use runtime::runner::{PortfolioRunner, Runner};
pub use sync_types::{ResourceSignature, ResourceType};
pub const CAPTURE_BACKTRACE: &str = "SHUTTLE_CAPTURE_BACKTRACE";
const RANDOM_SEED: &str = "SHUTTLE_RANDOM_SEED";
pub const SILENCE_WARNINGS: &str = "SHUTTLE_SILENCE_WARNINGS";
pub const ANNOTATION_FILE: &str = "SHUTTLE_ANNOTATION_FILE";
#[cfg(feature = "annotation")]
pub fn annotation_file() -> String {
std::env::var(ANNOTATION_FILE).unwrap_or_else(|_| "annotated.json".to_string())
}
pub fn silence_warnings() -> bool {
std::env::var(SILENCE_WARNINGS).is_ok()
}
pub fn backtrace_enabled() -> bool {
std::env::var(CAPTURE_BACKTRACE).is_ok()
}
pub fn seed_from_env(fallback_seed: u64) -> u64 {
let seed_env = std::env::var(RANDOM_SEED);
match seed_env {
Ok(s) => match s.as_str().parse::<u64>() {
Ok(seed) => {
tracing::info!(
"Initializing scheduler with the seed provided by {}: {}",
RANDOM_SEED,
seed
);
seed
}
Err(err) => panic!("The seed provided by {RANDOM_SEED} is not a valid u64: {err}"),
},
Err(_) => fallback_seed,
}
}