#[cfg(feature = "runtime-wasm")]
pub mod wasm;
#[cfg(feature = "runtime-deno")]
pub mod deno;
use std::future::Future;
use async_trait::async_trait;
use fraiseql_error::Result;
use crate::{
HostContext,
types::{EventPayload, FunctionModule, FunctionResult, ResourceLimits},
};
pub trait FunctionRuntime: Send + Sync {
fn invoke<H>(
&self,
module: &FunctionModule,
event: EventPayload,
host: &H,
limits: ResourceLimits,
) -> impl Future<Output = Result<FunctionResult>> + Send
where
H: HostContext + ?Sized;
fn supported_extensions(&self) -> &[&str];
fn supports_hot_reload(&self) -> bool;
fn name(&self) -> &str;
}
pub type BoxedFunctionRuntime = Box<dyn FunctionRuntime + Send + Sync>;
#[async_trait]
pub trait SendFunctionRuntime: Send + Sync {
async fn invoke_raw(
&self,
module: &FunctionModule,
event: EventPayload,
limits: ResourceLimits,
) -> Result<FunctionResult>;
fn supported_extensions(&self) -> &[&str];
fn supports_hot_reload(&self) -> bool;
fn name(&self) -> &str;
}