Real-Time Telemetry (SSE)
4. Real-Time Telemetry & Server-Sent Events (SSE)
Section titled “4. Real-Time Telemetry & Server-Sent Events (SSE)”Streaming Protocol (/v1/stream/{did})
Section titled “Streaming Protocol (/v1/stream/{did})”The SSE endpoint streams stages as they execute inside the Rust runtime:
GET /v1/stream/did:web:identity.foundation HTTP/1.1Host: did.isAccept: text/event-streamStream event lifecycle:
event: stage: Emitted on completion of each trace stage (startedUs,durationUs,status: PASS|FAIL).event: result: Emitted once with the fullEnrichedResolutionpayload.event: error: Emitted if resolution halts prematurely (carries RFC 9457 problem JSON).event: done: Emits{}and closes the stream.
Consuming SSE in TypeScript
Section titled “Consuming SSE in TypeScript”import { DidisClient } from "@didis/client";
const didis = new DidisClient();
async function streamDemo() { const iterator = didis.stream("did:web:identity.foundation", { noCache: true });
for await (const event of iterator) { if (event.event === "stage") { const { stage, status, durationUs } = event.data; console.log(`⏱️ [${status}] ${stage} (${durationUs} µs)`); } else if (event.event === "result") { console.log(`\n🎉 Resolution Complete: ${event.data.verdict.headline}`); } else if (event.event === "error") { console.error(`❌ Stream Failed: ${event.data.title}`); } }}
streamDemo();Consuming SSE in Python
Section titled “Consuming SSE in Python”from didis import DidisClient
with DidisClient() as client: for event_type, payload in client.stream("did:web:identity.foundation", no_cache=True): if event_type == "stage": print(f"⏱️ [{payload['status']}] {payload['stage']} ({payload['durationUs']} µs)") elif event_type == "result": print(f"\n🎉 Resolution Complete: {payload['verdict']['headline']}") elif event_type == "error": print(f"❌ Error: {payload['title']}")