Skip to main content

turn_config

Function turn_config 

Source
pub fn turn_config() -> Option<TurnConfig>
Expand description

Resolve TURN server config, highest priority first:

  1. An explicit MECHA10_WEBRTC_TURN_URL/_USERNAME/_CREDENTIAL env var set at runtime (today’s existing override behavior - see TurnServerConfig::from_env, packages/video/src/webrtc/connection.rs, and mecha10 dev’s maybe_inject_turn_credentials, packages/cli/src/handlers/dev/ops/spawn.rs).
  2. The build-time-baked option_env! default (LAB-1917).

Returns None when neither is present, so callers can fall through further to LAB-1915’s runtime API fetch from mecha10-api (tier 3, not implemented here - this function only ever resolves the first two tiers).

An empty URL - explicit or baked - is treated the same as unset (mirrors TurnServerConfig::from_env’s explicit-side check), so a deployment with no TURN server provisioned at all correctly falls through. The baked side matters in practice: a CI secret that isn’t provisioned yet (${{ secrets.MECHA10_WEBRTC_TURN_URL }} on an unset repo secret) still sets the env var cargo build sees to "" rather than leaving it unset, which would otherwise bake in Some("") and incorrectly short-circuit tier 3.