HTTP Streaming¶
When To Use¶
Use this archetype for the part of an HTTP device that emits activity through a long-lived notification stream, webhook-like feed, multipart stream, or long-poll endpoint. Requests and their replies (status reads, commands) follow HTTP Request-Reply on transport.type: http.
Core Shape¶
- requests and replies on the framework HTTP channel (
transport.type: http,HttpOperation<T>) - per-device stream state owned by the device's protocol, never by the shared transport
- long-lived event stream manager
- event translation layer from vendor payloads to PQ events
- optional status polling for device health and missing state
Typical Files¶
Communication/Transport.csCommunication/Protocol.csCommunication/<StreamManager>.csEvents/<Routing>.csCommands/*.csStatusPolling.csAdapterRegistrations.cs
Minimal Flow¶
HTTP stream -> stream manager -> transport callback -> event routing -> Thing method -> PQ event/status
command -> protocol queue -> HTTP request -> result
Minimal Pseudocode¶
public sealed record GetStatus() : HttpOperation<XDocument>("status")
{
public override HttpRequestMessage Build(Uri root) => Get(root, "status");
public override XDocument Parse(HttpReply reply) => XDocument.Parse(reply.Text);
}
var status = await Send(new GetStatus(), ct);
Common Pitfalls¶
- a shared HTTP client or per-device state on the shared transport: one device's retry disposes another device's client
- making concurrent HTTP calls when the device expects serialized access
- treating stream disconnects as non-fatal when they are the real health signal
- mixing event parsing logic into command handlers instead of a routing layer
- omitting polling when the stream does not cover all state
Good First Deliverable¶
Connect to the device, parse one streamed event type, and poll one health endpoint.