Skip to main content

Module server

Module server 

Source
Expand description

HTTP + WebSocket server that accepts audio and streams transcripts.

Single port serves both REST API (health, transcribe, SSE) and WebSocket.

Modules§

http
HTTP handlers for REST API endpoints.
metrics
Minimal Prometheus text-exposition registry (replaces metrics-exporter-prometheus).
rate_limit
Per-IP token-bucket rate limiter.

Structs§

OriginPolicy
Origin policy for CORS + cross-origin deny middleware.
RuntimeLimits
Runtime limits surfaced to per-request handlers. Separate from ServerConfig because it needs to travel through http::AppState to the WebSocket handler.
ServerConfig
Server runtime configuration. run_with_config is the canonical entry point; run / run_with_shutdown remain as thin wrappers for callers that only need the pre-0.6 positional parameters.

Enums§

FrameOutcome
Outcome returned by per-frame handlers. Keeps handle_ws_inner a thin orchestration loop instead of a 250-line one-big-match.

Functions§

handle_binary_frame
Handle a single PCM16 audio frame: resample if needed, run inference in a spawn_blocking guarded by catch_unwind, and emit partial/final/error payloads. Always returns the triplet to triplet_opt (or recovers a fresh state after an inference panic) so the connection can keep serving.
handle_ws
run
Start the HTTP + WebSocket STT server on the given host and port.
run_with_config
Start server with a full ServerConfig and optional programmatic shutdown signal. This is the canonical entry point — the other run_* helpers construct a default ServerConfig and dispatch here.
run_with_shutdown
Start server with an optional programmatic shutdown signal.
session_deadline_instant
Clamp shutdown_drain_secs to a minimum of 1 so the drain window is never zero-length (which would immediately kill in-flight tasks). fires in practice.
ws_handler
ws_handler_legacy
Deprecated WebSocket endpoint at /ws. Identical behaviour to /v1/ws but emits a warn-level log on every upgrade and adds RFC 8594 Deprecation plus Link: </v1/ws>; rel="successor-version" headers on the upgrade response so client libraries can surface the migration warning to users before v1.0 drops the alias.
ws_shutdown_response

Type Aliases§

WsSink