Creating a Worker
Creating a Worker
1use orcher::prelude::*;23#[workflow]4async fn process_order(ctx: WorkflowContext, order: Order) -> Result<Receipt> {5 let payment = ctx.execute_task(charge_payment, order.amount).await?;6 ctx.execute_task(send_confirmation, payment.id).await7}89#[task]10async fn charge_payment(ctx: TaskContext, amount: f64) -> Result<PaymentId> {11 Ok(PaymentId::new("pay_123"))12}1314#[task]15async fn send_confirmation(ctx: TaskContext, payment_id: PaymentId) -> Result<Receipt> {16 Ok(Receipt { id: payment_id })17}1819#[tokio::main(flavor = "current_thread")]20async fn main() -> Result<()> {21 let worker = Worker::builder()22 .server_url("http://localhost:50051")23 .namespace("default")24 .task_queue("orders")25 .identity("order-worker-1")26 .max_concurrent_workflows(100)27 .max_concurrent_tasks(200)28 .build()29 .await?;3031 worker.run().await32}Configuration
All SDKs support the same core configuration through their builder APIs. Defaults vary slightly between SDKs.
Core Options
| Option | Rust | Python | TypeScript | Description |
|---|---|---|---|---|
server_url | localhost:50051 | (required) | (required) | Orchestrator gRPC address |
namespace | default | default | (required) | Multi-tenancy namespace |
task_queue | (required) | (required) | (required) | Queue this worker polls |
identity | auto (UUID) | auto (timestamp) | auto (host-pid-ts) | Human-readable worker identity |
max_concurrent_workflows | 100 | 100 | 100 | Max workflows executing simultaneously |
max_concurrent_tasks | 200 | 100 | 100 | Max tasks executing simultaneously |
workflow_poller_count | 4 | 2 | 4 | Parallel workflow pollers |
task_poller_count | 4 | 4 | 4 | Parallel task pollers |
actor_poller_count | 4 | 4 | 2 | Parallel actor pollers |
heartbeat_interval | 10s | 10s | — (not configurable) | Registration heartbeat interval |
organization_id | — | — | — | Organization for multi-tenancy |
api_key | — | — | — | API key authentication |
build_id | — | — | versionId (default ORCHER_VERSION_ID) | Version identifier for deployments |
Security Options
1Worker::builder()2 .server_url("https://orchestrator:50051")3 .task_queue("orders")4 // AES-256-GCM payload encryption5 .with_encryption(&encryption_key)6 // gRPC compression7 .with_gzip_compression()8 // Custom interceptor for logging/auth9 .interceptor(LoggingInterceptor::new())10 .build()11 .await?Next Steps
- Connectivity — Registration, polling, heartbeats, and eager dispatch
- Scaling — Horizontal scaling, recovery, and performance tuning
- Operations — Graceful shutdown, monitoring, and troubleshooting