Skip to main content

invoke_function

Function invoke_function 

Source
pub async fn invoke_function(
    __arg0: State<Arc<AppState>>,
    __arg1: Path<Uuid>,
    tenant: Option<Extension<TenantId>>,
    auth: Option<Extension<AuthContext>>,
    payload: Result<Json<InvokeRequest>, JsonRejection>,
) -> ApiResult<Json<Value>>
Expand description

POST /functions/{id}/invoke — synchronous invocation.

Looks up the function’s stored Wasm bytes, spawns a fresh instance via the shared TensorWasmExecutor with a 30-second deadline, calls the requested export (defaulting to _startmain discovery) with the supplied args, then terminates the instance. Returns the function_id and a JSON result on success; structured ApiError otherwise.

The tenant id is sourced from the X-TensorWasm-Tenant middleware extension; absent it defaults to TenantId(0).

Body schema is InvokeRequest (both fields optional). An empty body is treated as the all-defaults case for client compatibility with the pre-args wire contract.