ccproxy.observability.sse_events¶
ccproxy.observability.sse_events
¶
Server-Sent Events (SSE) event manager for real-time dashboard updates.
This module provides centralized SSE connection management and event broadcasting for real-time dashboard notifications when requests start, complete, or error.
SSEEventManager
¶
Centralized SSE connection management and event broadcasting.
Manages multiple SSE connections and broadcasts events to all connected clients. Uses bounded queues to prevent memory issues with slow clients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_queue_size
|
int
|
Maximum events to queue per connection before dropping |
100
|
Source code in ccproxy/observability/sse_events.py
add_connection
async
¶
Add SSE connection and yield events as JSON strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_id
|
str | None
|
Unique connection identifier (generated if not provided) |
None
|
request_id
|
str | None
|
Request identifier for tracking |
None
|
Yields:
Type | Description |
---|---|
AsyncGenerator[str, None]
|
JSON-formatted event strings for SSE |
Source code in ccproxy/observability/sse_events.py
emit_event
async
¶
Broadcast event to all connected clients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
str
|
Type of event (request_start, request_complete, request_error) |
required |
data
|
dict[str, Any]
|
Event data dictionary |
required |
Source code in ccproxy/observability/sse_events.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
disconnect_all
async
¶
Disconnect all active connections gracefully.
Source code in ccproxy/observability/sse_events.py
get_connection_count
async
¶
get_connection_info
async
¶
Get connection status information.
Source code in ccproxy/observability/sse_events.py
get_sse_manager
¶
Get or create global SSE event manager.
emit_sse_event
async
¶
Convenience function to emit SSE event using global manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
str
|
Type of event (request_start, request_complete, request_error) |
required |
data
|
dict[str, Any]
|
Event data dictionary |
required |
Source code in ccproxy/observability/sse_events.py
cleanup_sse_manager
async
¶
Clean up global SSE manager and disconnect all clients.