Expand description
Session layer — the primary interface for the Gemini Live API.
Session manages the full connection lifecycle: WebSocket connect,
setup handshake, automatic reconnection, and typed send/receive.
Because Live API WebSocket sessions are finite-lived, this layer also owns
goAway handling and session-resumption handoff.
§Architecture
┌──────────────┐
│ Session │ ← cheap Clone (Arc)
│ (handle) │
└──┬───────┬───┘
cmd_tx │ │ event_rx (broadcast)
▼ ▼
┌─────────────────────────────────┐
│ Runner task │ ← tokio::spawn
│ ┌───────────┐ ┌────────────┐ │
│ │ Send Loop │ │ Recv Loop │ │
│ │ (ws sink) │ │ (ws stream)│ │
│ └───────────┘ └────────────┘ │
│ reconnect · GoAway · resume │
└─────────────────────────────────┘The runner is a single tokio::spawn’d task that uses tokio::select!
to multiplex user commands and WebSocket frames. Reconnection is
transparent — messages buffer in the mpsc channel during downtime.
Structs§
- Reconnect
Policy - Reconnection behaviour after an unexpected disconnect or
goAway. - Session
- An active session with the Gemini Live API.
- Session
Config - Complete session configuration combining transport, protocol, and reconnection settings.
Enums§
- Session
Observation - Observable items from the session receive cursor.
- Session
Status - Observable session state.