Transport¶
Base Transport Interface¶
Transport ¶
Bases: ABC
Abstract base class for PhyCloud transports.
Implementations must provide async methods for sending single events and batches to PhyCloud endpoints.
Initialize the transport.
| PARAMETER | DESCRIPTION |
|---|---|
config | Transport configuration TYPE: |
Source code in phytrace/transport/base.py
Attributes¶
Functions¶
connect abstractmethod async ¶
Establish connection to PhyCloud.
| RAISES | DESCRIPTION |
|---|---|
TransportError | If connection fails |
disconnect abstractmethod async ¶
send abstractmethod async ¶
send(event: UDMEvent) -> SendResult
Send a single event to PhyCloud.
| PARAMETER | DESCRIPTION |
|---|---|
event | The UDM event to send TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
SendResult | SendResult indicating success or failure |
send_batch abstractmethod async ¶
send_batch(events: list[UDMEvent]) -> BatchSendResult
Send a batch of events to PhyCloud.
| PARAMETER | DESCRIPTION |
|---|---|
events | List of UDM events to send TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
BatchSendResult | BatchSendResult with per-event results |
Source code in phytrace/transport/base.py
health_check async ¶
Check if the transport connection is healthy.
| RETURNS | DESCRIPTION |
|---|---|
bool | True if healthy, False otherwise |
SendResult¶
SendResult dataclass ¶
SendResult(success: bool, event_id: str, timestamp: datetime = now_utc(), error: TransportError | None = None, response_time_ms: float | None = None, server_event_id: str | None = None)
Result of sending a single event.
Functions¶
ok classmethod ¶
ok(event_id: str, response_time_ms: float | None = None, server_event_id: str | None = None) -> SendResult
Create a successful result.
Source code in phytrace/transport/base.py
fail classmethod ¶
fail(event_id: str, error: TransportError) -> SendResult
BatchSendResult¶
BatchSendResult dataclass ¶
BatchSendResult(success: bool, total_events: int, successful_events: int, failed_events: int, results: list[SendResult] = list(), batch_id: str | None = None, response_time_ms: float | None = None)
HTTP Transport¶
HTTPTransport ¶
HTTPTransport(endpoint: str, api_key: str | None = None, timeout_sec: float = 30.0, max_retries: int = 3, api_version: str = 'v1')
Bases: Transport
HTTP/REST transport for PhyCloud ingestion.
Sends events to PhyCloud using the REST API: - POST /api/v1/events - Single event - POST /api/v1/events/batch - Multiple events
The endpoint is treated as a base URL (e.g. https://api.phycloud.phyware.io or http://127.0.0.1:8000). The API version path (/api/v1) is appended internally so the SDK always targets the path PhyCloud actually serves. For back-compat, endpoints that already include a trailing /v1 or /api/v1 are normalized at request time.
Initialize HTTP transport.
| PARAMETER | DESCRIPTION |
|---|---|
endpoint | PhyCloud base URL (e.g. TYPE: |
api_key | API key for authentication TYPE: |
timeout_sec | Request timeout in seconds TYPE: |
max_retries | Maximum retry attempts TYPE: |
api_version | PhyCloud API version segment (default TYPE: |
Source code in phytrace/transport/http.py
Functions¶
connect async ¶
Establish HTTP session.
Source code in phytrace/transport/http.py
disconnect async ¶
send async ¶
send(event: UDMEvent) -> SendResult
Send a single event to PhyCloud.
| PARAMETER | DESCRIPTION |
|---|---|
event | The UDM event to send TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
SendResult | SendResult indicating success or failure |
Source code in phytrace/transport/http.py
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 197 198 199 200 201 202 | |
send_batch async ¶
send_batch(events: list[UDMEvent]) -> BatchSendResult
Send a batch of events to PhyCloud.
| PARAMETER | DESCRIPTION |
|---|---|
events | List of UDM events to send TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
BatchSendResult | BatchSendResult with per-event results |
Source code in phytrace/transport/http.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
Mock Transport¶
MockTransport ¶
Bases: Transport
Mock transport for testing.
Records all sent events and allows configuring behavior for testing different scenarios.
Example
transport = MockTransport() await transport.send(event)
assert len(transport.sent_events) == 1 assert transport.sent_events[0].source_id == "robot-001"
Test error handling¶
transport.behavior.fail_all = True result = await transport.send(event) assert not result.success
Initialize mock transport.
| PARAMETER | DESCRIPTION |
|---|---|
behavior | Optional MockBehavior configuration TYPE: |
Source code in phytrace/transport/mock.py
Attributes¶
Functions¶
connect async ¶
disconnect async ¶
send async ¶
send(event: UDMEvent) -> SendResult
Mock send - records the event and returns configured result.
| PARAMETER | DESCRIPTION |
|---|---|
event | The UDM event to "send" TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
SendResult | SendResult based on configured behavior |
Source code in phytrace/transport/mock.py
send_batch async ¶
send_batch(events: list[UDMEvent]) -> BatchSendResult
Mock batch send - records all events.
| PARAMETER | DESCRIPTION |
|---|---|
events | List of UDM events to "send" TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
BatchSendResult | BatchSendResult based on configured behavior |
Source code in phytrace/transport/mock.py
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |