Operations

Creating a Worker


Creating a Worker

1
use orcher::prelude::*;
2
3
#[workflow]
4
async 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).await
7
}
8
9
#[task]
10
async fn charge_payment(ctx: TaskContext, amount: f64) -> Result<PaymentId> {
11
Ok(PaymentId::new("pay_123"))
12
}
13
14
#[task]
15
async fn send_confirmation(ctx: TaskContext, payment_id: PaymentId) -> Result<Receipt> {
16
Ok(Receipt { id: payment_id })
17
}
18
19
#[tokio::main(flavor = "current_thread")]
20
async 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?;
30
31
worker.run().await
32
}

Configuration

All SDKs support the same core configuration through their builder APIs. Defaults vary slightly between SDKs.

Core Options

OptionRustPythonTypeScriptDescription
server_urllocalhost:50051(required)(required)Orchestrator gRPC address
namespacedefaultdefault(required)Multi-tenancy namespace
task_queue(required)(required)(required)Queue this worker polls
identityauto (UUID)auto (timestamp)auto (host-pid-ts)Human-readable worker identity
max_concurrent_workflows100100100Max workflows executing simultaneously
max_concurrent_tasks200100100Max tasks executing simultaneously
workflow_poller_count424Parallel workflow pollers
task_poller_count444Parallel task pollers
actor_poller_count442Parallel actor pollers
heartbeat_interval10s10s— (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

1
Worker::builder()
2
.server_url("https://orchestrator:50051")
3
.task_queue("orders")
4
// AES-256-GCM payload encryption
5
.with_encryption(&encryption_key)
6
// gRPC compression
7
.with_gzip_compression()
8
// Custom interceptor for logging/auth
9
.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