#[cfg(feature = "faas")]
pub use blueprint_faas::*;
#[cfg(not(feature = "faas"))]
mod stub {
use blueprint_core::{JobCall, JobResult};
use std::fmt;
use std::sync::Arc;
#[derive(Debug)]
pub struct FaasError;
impl std::fmt::Display for FaasError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "FaaS feature not enabled")
}
}
impl std::error::Error for FaasError {}
#[async_trait::async_trait]
pub trait FaasExecutor: Send + Sync + fmt::Debug {
async fn invoke(&self, _job_call: JobCall) -> Result<JobResult, FaasError> {
Err(FaasError)
}
fn provider_name(&self) -> &'static str {
"stub"
}
}
#[derive(Default, Debug)]
pub struct FaasRegistry;
impl FaasRegistry {
#[must_use]
pub fn new() -> Self {
Self
}
pub fn register(&mut self, _job_id: u32, _executor: Arc<dyn FaasExecutor>) {}
#[must_use]
pub fn get(&self, _job_id: u32) -> Option<&Arc<dyn FaasExecutor>> {
None
}
#[must_use]
pub fn is_faas_job(&self, _job_id: u32) -> bool {
false
}
pub fn job_ids(&self) -> impl Iterator<Item = u32> {
std::iter::empty()
}
}
}
#[cfg(not(feature = "faas"))]
pub use stub::*;