Add WebAPIResponseEventStream for API streaming results.
Review Request #13281 — Created Sept. 21, 2023 and submitted
This builds upon the new
EventStreamHttpResponseclass to easily
enable APIs to stream events and results to callers using Server-Sent
Events.
WebAPIResourcehandlers can now return a generator or generator
function that yields messages for the event stream. These will be
serialized one-by-one using the same API response serialization logic we
otherwise use for the API. Callers can parse those as they come in,
utilizing aX-Event-Data-Mimetypeheader to know the resource type for
any "message" events (the default wheneventisn't specified) to
intelligently handle parsing.This can be used for HTTP GET/POST/PUT requests, making it possible to
stream progress notification or build a message bus using the API.
Unit tests pass.
Tested this with an
EventSourcein JavaScript, verifying that events
were properly coming in and could be parsed correctly.
| Summary | ID |
|---|---|
| b3e7dc50f6caa1e33e2ef15528c1c86a6f23b292 |
| Description | From | Last Updated |
|---|---|---|
|
'djblets.http.responses.EventStream' imported but unused Column: 1 Error code: F401 |
|