Skip to main content

Module worker_client

Module worker_client 

Source
Expand description

Worker-side gRPC client for ZLayer’s worker tier.

Lifecycle:

  1. On startup: load persisted mTLS identity (cert + key) if present; otherwise read the bootstrap token, generate a fresh EC P-256 keypair, build a PKCS#10 CSR, call Register, persist the signed cert + key
    • ca chain under <data_dir>/worker/identity/.
  2. Background loops (each spawned as its own JoinHandle):
    • WatchAssignments: server-streaming; receive AssignmentEvents and forward them via assignment_tx to the agent’s executor.
    • ReportStatus: bidi-streaming; tick at (next_ttl_secs - jitter) sending a StatusReport snapshot; receive StatusAck and update next_ttl_secs.
    • WatchCommands: server-streaming; receive CommandEvents and forward via command_tx.
  3. On disconnect: exponential backoff capped at 60s; on reconnect send a full snapshot (StatusReport.full_snapshot = true).

Implements zlayer_scheduler::cluster::WorkerClient so a WorkerTierCluster in worker mode can route Cluster trait calls through this.

Structs§

WorkerClientImpl
Worker-side gRPC client. Construct via WorkerClientImpl::new, then spawn the background loops with WorkerClientImpl::start.
WorkerIdentity
Worker mTLS identity persisted to disk.

Enums§

WorkerClientError
Errors produced by the worker client.

Traits§

WorkerStatusProvider
Status snapshot provider for the worker. The agent’s ServiceManager implements this so the worker client can report current container state