Skip to content

Commit cdb33ab

Browse files
committed
Update doc
1 parent 6da98dd commit cdb33ab

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ If you have never used AWS Lambda before, check out this getting started guide.
3333
To create a simple lambda function, follow the following steps:
3434
1. Create Kotlin multiplatform project
3535
2. Include library dependency into your module-level build.gradle file
36-
```
36+
```kotlin
37+
//..
3738
kotlin {
3839
//..
3940
sourceSets {
@@ -44,9 +45,11 @@ kotlin {
4445
}
4546
//..
4647
}
48+
//..
4749
```
4850
3. Specify application entry point reference and supported targets
49-
```
51+
```kotlin
52+
//..
5053
kotlin {
5154
//..
5255
listOf(
@@ -63,16 +66,16 @@ kotlin {
6366
}
6467
//..
6568
}
69+
//..
6670
```
6771
4. Choose lambda function type.
6872

6973
There are two types of lambda functions:
7074

71-
** Buffered **
72-
Buffered functions process incoming events by first collecting them
75+
**Buffered** functions process incoming events by first collecting them
7376
into a buffer before execution. This is a default behavior.
7477

75-
```
78+
```kotlin
7679
class HelloWorldLambdaHandler : LambdaBufferedHandler<APIGatewayV2Request, APIGatewayV2Response> {
7780
override suspend fun handleRequest(input: APIGatewayV2Request, context: Context): APIGatewayV2Response {
7881
return APIGatewayV2Response(
@@ -86,13 +89,12 @@ class HelloWorldLambdaHandler : LambdaBufferedHandler<APIGatewayV2Request, APIGa
8689
}
8790
```
8891

89-
** Streaming **
90-
Streaming functions, on the other hand, process events in real-time as they arrive, without any
92+
**Streaming** functions, on the other hand, process events in real-time as they arrive, without any
9193
intermediate buffering. This method is well-suited for use cases requiring immediate data
9294
processing, such as real-time analytics or event-driven architectures where low-latency responses
9395
are crucial.
9496

95-
```
97+
```kotlin
9698
class SampleStreamingHandler : LambdaStreamHandler<ByteArray, ByteWriteChannel> {
9799
override suspend fun handleRequest(input: ByteArray, output: ByteWriteChannel, context: Context) {
98100
ByteReadChannel(SystemFileSystem.source(Path("hello.json")).buffered()).copyTo(output)
@@ -101,7 +103,7 @@ class SampleStreamingHandler : LambdaStreamHandler<ByteArray, ByteWriteChannel>
101103
```
102104

103105
5. Specify application entry point using standard `main` and `LambdaRuntime.run` functions
104-
```
106+
```kotlin
105107
fun main() = LambdaRuntime.run { HelloWorldLambdaHandler() } // or SampleStreamingHandler for streaming lambda
106108
```
107109

0 commit comments

Comments
 (0)