@syi0808/worker
v0.26.6
Published
Worker SDK for Aiki - execute workflows and tasks with durable state management and automatic recovery
Downloads
679
Readme
@syi0808/worker
Worker SDK for Aiki durable execution platform.
Installation
npm install @syi0808/workerQuick Start
import { worker } from "@syi0808/worker";
import { client } from "@syi0808/client";
import { orderWorkflowV1 } from "./workflows.ts";
const aikiClient = client({
url: "http://localhost:9850",
apiKey: "your-api-key",
});
const aikiWorker = worker({
workflows: [orderWorkflowV1],
});
const handle = await aikiWorker.spawn(aikiClient);
// Graceful shutdown
process.on("SIGTERM", async () => {
await handle.stop();
process.exit(0);
});Features
- Horizontal Scaling - Run multiple workers to share workload
- Automatic Recovery - Resume from failures without losing progress
- Heartbeat Monitoring - Detect and recover stuck workflows
- Graceful Shutdown - Complete active work before stopping
- Sharding - Route workflows to specific workers
- Pluggable Subscribers - Swap work discovery transport (DB polling default, Redis Streams via
@syi0808/redis, or bring your own)
Documentation
For comprehensive documentation including scaling strategies, configuration options, and how workers operate, see the Workers Guide.
Related Packages
- @syi0808/client - Connect to Aiki server
- @syi0808/workflow - Define workflows and tasks
License
Apache-2.0
