Skip to content

Commit 9b8a71c

Browse files
committed
cleanup the example README
1 parent a0eb791 commit 9b8a71c

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

Examples/Streaming/README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ try await responseWriter.writeStatusAndHeaders(
2626
headers: [
2727
"Content-Type": "text/plain",
2828
"x-my-custom-header": "streaming-example"
29-
],
30-
multiValueHeaders: [
31-
"Set-Cookie": ["session=abc123", "theme=dark"]
3229
]
3330
)
3431
)
@@ -37,15 +34,14 @@ try await responseWriter.writeStatusAndHeaders(
3734
The `StreamingLambdaStatusAndHeadersResponse` structure allows you to specify:
3835
- **statusCode**: HTTP status code (e.g., 200, 404, 500)
3936
- **headers**: Dictionary of single-value HTTP headers (optional)
40-
- **multiValueHeaders**: Dictionary of multi-value HTTP headers like Set-Cookie (optional)
4137

4238
### Streaming the Response Body
4339

4440
After setting headers, you can stream the response body by calling the `write(_:)` function of the `LambdaResponseStreamWriter` with partial data repeatedly before finally closing the response stream by calling `finish()`. Developers can also choose to return the entire output and not stream the response by calling `writeAndFinish(_:)`.
4541

4642
```swift
4743
// Stream data in chunks
48-
for i in 1...10 {
44+
for i in 1...3 {
4945
try await responseWriter.write(ByteBuffer(string: "Number: \(i)\n"))
5046
try await Task.sleep(for: .milliseconds(1000))
5147
}
@@ -98,7 +94,7 @@ aws lambda create-function \
9894
```
9995

10096
> [!IMPORTANT]
101-
> The timeout value must be bigger than the time it takes for your function to stream its output. Otherwise, the Lambda control plane will terminate the execution environment before your code has a chance to finish writing the stream. Here, the sample function stream responses during 10 seconds and we set the timeout for 15 seconds.
97+
> The timeout value must be bigger than the time it takes for your function to stream its output. Otherwise, the Lambda control plane will terminate the execution environment before your code has a chance to finish writing the stream. Here, the sample function stream responses during 3 seconds and we set the timeout for 5 seconds.
10298
10399
The `--architectures` flag is only required when you build the binary on an Apple Silicon machine (Apple M1 or more recent). It defaults to `x64`.
104100

@@ -169,13 +165,7 @@ This should output the following result, with a one-second delay between each nu
169165
1
170166
2
171167
3
172-
4
173-
5
174-
6
175-
7
176-
8
177-
9
178-
10
168+
Streaming complete!
179169
```
180170

181171
### Undeploy

Examples/Streaming/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Resources:
88
Type: AWS::Serverless::Function
99
Properties:
1010
CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/StreamingNumbers/StreamingNumbers.zip
11-
Timeout: 15
11+
Timeout: 5 # Must be bigger than the time it takes to stream the output
1212
Handler: swift.bootstrap # ignored by the Swift runtime
1313
Runtime: provided.al2
1414
MemorySize: 128

0 commit comments

Comments
 (0)