Overview
Serverless compute that scales to zero, triggered by HTTP, queues, storage events, or cron.
Worker provides event-driven, stateless compute. Workers handle HTTP requests, process queue messages, react to storage events, or run on a schedule. They scale automatically with load and scale to zero when idle.
Platform Mapping
| Platform | Backing Service | Provisioned by |
|---|---|---|
| AWS | AWS Lambda (ARM64/Graviton) | Alien |
| GCP | Google Cloud Run | Alien |
| Azure | Azure Container Apps | Alien |
| Kubernetes / On-Prem | Deployment + Service | Alien Operator |
When to Use
Use Worker for event-driven, stateless compute — HTTP APIs, webhook handlers, background processors, queue consumers, scheduled tasks.
Don't use Worker for long-running stateful workloads, persistent WebSocket connections, or services that need internal DNS discovery.
Quick Start
// alien.ts
const api = new alien.Worker("api")
.code({ type: "source", src: "./api", toolchain: { type: "typescript" } })
.publicEndpoint("api")
.permissions("execution")
.build()Public Endpoints
Workers are private by default. Add named public endpoints when the worker should receive HTTPS traffic.
const api = new alien.Worker("api")
.publicEndpoint("api")
.build()Use endpoint names for roles such as "api", "webhooks", or "admin". See External URLs.
Worker-to-Worker Invocation
Workers can call other workers directly — low-latency internal calls that bypass public endpoints:
import { worker } from "@alienplatform/sdk"
const processor = await worker("image-processor")
const result = await processor.invokeJson("resize", { imageUrl: "...", width: 800 })let processor = ctx.bindings().load_worker("image-processor").await?;
let response = processor.invoke(WorkerInvokeRequest {
target_worker: "image-processor".to_string(),
method: "POST".to_string(),
path: "/resize".to_string(),
headers: BTreeMap::new(),
body: serde_json::to_vec(&payload)?,
timeout: Some(Duration::from_secs(30)),
}).await?;Configuration
| Method | Default | Description |
|---|---|---|
.code(code) | required | Source code or pre-built image. See Toolchains. |
.publicEndpoint(name, options?) | — | Adds a named HTTPS endpoint. Omit for private workers. |
.memoryMb(number) | 256 | Memory allocation. 128–32,768 MB. |
.timeoutSeconds(number) | 180 | Max execution time. 1–3,600 seconds. |
.concurrencyLimit(number) | platform default | Max concurrent executions. Maps to reserved concurrency (Lambda), max instances (Cloud Run), or max replicas (Container Apps). |
.commandsEnabled(boolean) | false | Enable the remote command protocol. |
.readinessProbe({ method, path }) | — | Health check after deploy. Only used when the worker has public endpoints. |
.environment(Record) | {} | Environment variables. |
.link(resource) | — | Connect to a resource for binding access. Can be called multiple times. |
.trigger(trigger) | — | Add an event trigger. Can be called multiple times. |
.permissions(string) | required | Permission profile name. |
Triggers
// Queue trigger — one message per invocation
const worker = new alien.Worker("processor").trigger(tasks).build()
// In worker code:
import { onQueueMessage, onStorageEvent } from "@alienplatform/sdk"
onQueueMessage("tasks", async (msg) => { /* ... */ })
onStorageEvent("uploads", async (event) => { /* ... */ })