Gemini.Streaming.Manager (GeminiEx v0.0.1)

View Source

GenServer for managing streaming connections and state.

This GenServer handles:

  • Managing multiple concurrent streaming sessions
  • Buffering and parsing Server-Sent Events
  • Maintaining connection state and metadata
  • Automatic reconnection and error recovery

Summary

Functions

Returns a specification to start this module under a supervisor.

Get information about a specific stream.

Get the current status of a stream.

List all active streams.

Start a new streaming session with contents and options. (Alternative signature for compatibility)

Stop a streaming session.

Subscribe to events from a streaming session.

Subscribe to events from a streaming session. (Alias for subscribe/2)

Unsubscribe from a streaming session.

Types

state()

@type state() :: %{
  streams: %{required(stream_id()) => stream_state()},
  stream_counter: non_neg_integer()
}

stream_id()

@type stream_id() :: String.t()

stream_state()

@type stream_state() :: %{
  stream_id: stream_id(),
  pid: pid(),
  auth_type: atom(),
  credentials: map(),
  model: String.t(),
  endpoint: String.t(),
  request_body: map(),
  buffer: String.t(),
  status: :active | :completed | :error,
  error: term() | nil,
  events: [map()],
  subscribers: [pid()]
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_stream_info(stream_id)

Get information about a specific stream.

get_stream_status(stream_id)

Get the current status of a stream.

list_streams()

List all active streams.

start_link(opts \\ [])

start_stream(contents, opts, subscriber_pid)

Start a new streaming session with contents and options. (Alternative signature for compatibility)

start_stream(auth_type, credentials, model, endpoint, request_body, opts \\ [])

Start a new streaming session.

Returns a stream ID that can be used to subscribe to events.

stop_stream(stream_id)

Stop a streaming session.

subscribe(stream_id, subscriber_pid \\ self())

Subscribe to events from a streaming session.

subscribe_stream(stream_id, subscriber_pid \\ self())

Subscribe to events from a streaming session. (Alias for subscribe/2)

unsubscribe(stream_id, subscriber_pid \\ self())

Unsubscribe from a streaming session.