Skip to main content

Module worker_pool

Module worker_pool 

Source
Expand description

Worker pool with isolation primitives (plan #36).

Borrowed from MAX’s serve/worker_interface/. The serving pattern: engines run in workers (eventually subprocesses); a main router forwards requests via IPC. One worker crashing doesn’t take the server down.

This module ships the in-process layer (testable, deterministic) plus the trait surface that a future SubprocessWorker will implement. The IPC plumbing (stdin/stdout JSON-lines, recovery on crash) is intentionally out of scope until a serving binary consumes it; we’d rather build it once against a real consumer than build it twice.

Structs§

InProcessWorker
In-process worker — runs the handler closure inline. Useful for tests and for single-process serving. Tracks in-flight / completed / errored counts atomically.
WorkerHealth
WorkerId
Stable worker identifier.
WorkerPool
Pool of workers. Generic over (Req, Resp); works with the Worker trait directly.

Enums§

DispatchPolicy
Pool dispatch policy.
WorkerError

Traits§

Worker
Trait every worker implements. Req and Resp are caller-defined; the future subprocess flavour will use a serde-friendly wire type as both parameters.