Open jonaro00 opened 5 months ago
Pulling out a summary of this idea from a Discord discussion.
The proposal would be to accept user code and execute it on the Shuttle runtime in a Function-as-a-Service manner - made famous by AWS Lambda.
Below is an example of what user code to register a Shuttle FaaS might look like:
#[derive(serde::Serialize)]
pub struct CalculationResult {
z: f64,
}
#[derive(serde::Deserialize)]
pub struct CalculationInput {
x: f64,
y: f64,
}
pub enum Error {
InternalError,
}
// More hands-on way of exposing a lambda-like endpoint
#[shuttle_runtime::faas_post("/mutliply")]
pub async fn multiply(input: CalculationInput) -> Result<CalculationResult, Error> {
Ok(CalculationResult {
z: input.x * input.y,
})
}
// Could it be simplified such that someone would only need to do the below? Shuttle
// would then generate the JSON types
#[shuttle_runtime::faas_post("/multiply_simple")]
pub async fn multiply_simple(x: f64, y: f64) -> f64 {
x * y
}
ShuttleFaas
result object?Adding some more benefits that a FaaS model might bring to both users and the platform, largely due to the request-scoped nature of FaaS:
Deploy AWS Lambdas using Shuttle
This issue is a part of the Product Feature Poll (all issues). React with :+1: if you want this feature. Comment if you have suggestions related to this feature.