Overview
The Worker API provides:- Bidirectional gRPC streaming for worker-scheduler communication
- Worker registration with platform properties
- Task assignment and status updates
- Keep-alive heartbeat mechanism
- Graceful worker shutdown
- Long-lived bidirectional streaming connection
- Platform property-based worker matching
- Automatic timeout detection
- Action result reporting
Configuration
Reference to the scheduler that manages workers
gRPC Methods
ConnectWorker
Establish a bidirectional stream between worker and scheduler. Request (stream): Workers sendUpdateForScheduler messages:
Unique worker identifier (generated if not provided)
Worker capabilities (CPU, memory, OS, etc.)
Heartbeat to indicate worker is alive
Signal that worker is shutting down
Action execution result (exit code, outputs)
UpdateForWorker messages:
Time until next keep-alive expected
Action to execute:
operation_id: Unique operation identifieraction_digest: Digest of the Action to executeskip_cache_lookup: Whether to skip AC lookupplatform_properties: Required platform properties
Connection Flow
Worker initiates connection
Worker calls ConnectWorker and sends initial UpdateForScheduler with platform_properties
Worker Registration
Workers register by sending their platform properties:Workers must send keep-alive messages within the update_timeout period
Execution Results
Workers report results via execute_result:Worker Timeout
Workers that fail to send updates within the timeout period are:- Marked as timed out
- Removed from the available worker pool
- Any assigned actions are rescheduled
Configuration Example
Complete worker configuration:Monitoring
Key metrics to monitor:- Active worker count
- Worker connection duration
- Task assignment rate
- Worker timeout rate
- Average execution time
Error Codes
| Code | Description |
|---|---|
INVALID_ARGUMENT | Invalid worker_id or platform properties |
NOT_FOUND | Scheduler not configured |
DEADLINE_EXCEEDED | Worker timed out |
CANCELLED | Connection closed |
Implementation Details
Fromnativelink-service/src/worker_api_server.rs:
Workers use a custom NativeLink protocol over gRPC, not the standard Remote Execution API