You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add section on supported content types and streaming options
Add a section to the workload page to list the supported HTTP streaming
options: SSE, Websockets and NDJSON.
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
Copy file name to clipboardExpand all lines: docs/reference/workloads.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,3 +240,37 @@ fprocess=env
240
240
HOME=/home/app
241
241
Http_X_Forwarded_Proto=https
242
242
```
243
+
244
+
### Supported content types
245
+
246
+
OpenFaaS supports workloads over HTTP, and most standard content types are supported.
247
+
248
+
Since OpenFaaS has no hard limit on function execution duration, it allows for maintaining long-lived connections for streaming over HTTP.
249
+
250
+
> **Important**: Always ensure OpenFaaS system and function timeouts are configured appropriately for your streaming workloads. See [Extended timeouts](https://docs.openfaas.com/tutorials/expanded-timeouts/) for details.
251
+
252
+
Supported streaming options:
253
+
254
+
**Server-Sent Events (SSE)**
255
+
256
+
Server-Sent Events enable a function to push one-way event streams to a client.
257
+
258
+
- Clients should include an `Accept: text/event-stream` header in their request when starting tht SSE request.
259
+
- The function's response `Content-Type` header must be set to `text/event-stream`. Each event data chunk should be prefixed with data: and terminated by two newline characters (\n\n).
260
+
261
+
For more details on SSE, refer to [Using Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
262
+
263
+
**WebSockets**
264
+
265
+
WebSockets provide bidirectional, full-duplex communication between a client and an OpenFaaS function.
266
+
267
+
To create a WebSocket-enabled function, you can modify an existing OpenFaaS template or use the `Dockerfile` template as a starting point.
268
+
269
+
For a comprehensive guide, check out: [How to Integrate WebSockets with Serverless Functions and OpenFaaS](https://www.openfaas.com/blog/serverless-websockets/)
270
+
271
+
**Newline Delimited JSON (NDJSON)**
272
+
273
+
NDJSON (or JSON Lines) is a format for streaming multiple independent JSON objects, each on a new line.
274
+
275
+
- Clients should include an `Accept: application/x-ndjson` header in their request.
276
+
- The function's response `Content-Type` header should be set to `application/x-ndjson`. Each line in the response should be a complete JSON object followed by a newline character (\n).
0 commit comments