Skip to main content

Module worker

Module worker 

Source
Expand description

The agent worker: one process, one registered UA (with catchall), driven over stdio with the proto framed protocol. Because each worker is its own process it binds its own SIP socket, so the provider routes incoming calls to this registration by contact address — which in-process multi-UA cannot do (one shared socket, and the request-URI user need not identify the UA, so there’s no way to demux).

Channels: stdin carries the crate::AgentConfig handshake (first frame) then command/query control frames + inbound audio frames; stdout carries event/reply/header control frames + received-audio frames (a single writer thread serialises them, so frames never interleave); stderr carries logs / SIP traces.

Functions§

per_agent_path
Insert a per-agent tag before the file extension: run.log -> run.<name>.<pid>.log. The name is sanitised (no path separators / dots, so it can’t escape the directory) and the worker PID disambiguates same-named agents across scenarios so their truncating logs don’t clobber each other. Public so a parent can locate a worker’s file (see ProcessClient::pid).
run
Run the worker: read the config handshake, spawn the backend, then pump stdin (commands/queries) and stdout (events/replies/headers) until stdin closes (EOF) or a Shutdown command arrives.