API Reference
Complete API reference for Alien Function bindings.
The Function binding enables direct function-to-function invocation — low-latency internal calls that bypass public endpoints.
invoke
Invokes a function with a full HTTP request.
const response = await func.invoke(request)
// response: { status: number, headers: Record<string, string>, body: Uint8Array }let response = func.invoke(FunctionInvokeRequest {
target_function: "processor".into(),
method: "POST".into(),
path: "/resize".into(),
headers: BTreeMap::new(),
body: payload_bytes,
timeout: Some(Duration::from_secs(30)),
}).await?;| Parameter | Type | Required | Description |
|---|---|---|---|
request.targetFunction | string | Yes | Function name or identifier. |
request.method | string | Yes | HTTP method (GET, POST, PUT, DELETE, etc.). |
request.path | string | Yes | Request path (e.g., /resize). |
request.headers | Record<string, string> | No | HTTP headers. |
request.body | Uint8Array | No | Request body as bytes. |
request.timeoutMs | number | No | Timeout in milliseconds. |
Returns: FunctionInvokeResponse — { status: number, headers: Record<string, string>, body: Uint8Array }
invokeJson
High-level JSON invocation with typed request and response.
const result = await func.invokeJson<TReq, TRes>(
targetFunction: string,
body: TReq,
options?: {
method?: string // default: "POST"
path?: string // default: "/"
headers?: Record<string, string>
timeoutMs?: number
}
): Promise<TRes>Automatically serializes the request body as JSON and parses the response body as JSON.
get
Convenience method for GET requests with a typed JSON response.
const result = await func.get<TRes>(
targetFunction: string,
path?: string,
options?: {
headers?: Record<string, string>
timeoutMs?: number
}
): Promise<TRes>getUrl
Returns the function's public URL, if it has public ingress configured.
const url = await func.getUrl(): Promise<string | undefined>async fn get_function_url(&self) -> Result<Option<String>>Returns undefined / None if the function has private ingress only.
Types
FunctionInvokeRequest
interface FunctionInvokeRequest {
targetFunction: string
method: string
path: string
headers?: Record<string, string>
body?: Uint8Array
timeoutMs?: number
}pub struct FunctionInvokeRequest {
pub target_function: String,
pub method: String,
pub path: String,
pub headers: BTreeMap<String, String>,
pub body: Vec<u8>,
pub timeout: Option<Duration>,
}FunctionInvokeResponse
interface FunctionInvokeResponse {
status: number
headers: Record<string, string>
body: Uint8Array
}pub struct FunctionInvokeResponse {
pub status: u16,
pub headers: BTreeMap<String, String>,
pub body: Vec<u8>,
}