Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 8ca41c8

Browse files
Add Swift Documentation
1 parent 434f4de commit 8ca41c8

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

Sources/LambdaSwiftSprinterNioPlugin/LambdaApiNIO.swift

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,45 @@ import NIO
2222
import NIOHTTP1
2323
import NIOFoundationCompat
2424

25+
/**
26+
`SprinterNIO` implements the AWS Lambda Custom Runtime with `SwiftNIO`
27+
*/
2528
public typealias SprinterNIO = Sprinter<LambdaApiNIO>
2629

30+
31+
/**
32+
SprinterNIOError
33+
An error related to the `SprinterNIO`
34+
35+
### Errors: ###
36+
```
37+
case invalidResponse(HTTPResponseStatus)
38+
case invalidBuffer
39+
```
40+
*/
2741
public enum SprinterNIOError: Error {
42+
43+
/// Invalid Reponse with `HTTPResponseStatus`
2844
case invalidResponse(HTTPResponseStatus)
45+
46+
/// Invalid Buffer
2947
case invalidBuffer
3048
}
3149

50+
/** The amount of time the lambda waits for the next event.
51+
52+
The `default` timeout for a Lambda is `3600` seconds.
53+
*/
3254
public var lambdaRuntimeTimeout: TimeAmount = .seconds(3600)
55+
56+
/// The timeout used to create the instance of the `httpClient`
3357
public var timeout = HTTPClient.Configuration.Timeout(connect: lambdaRuntimeTimeout,
3458
read: lambdaRuntimeTimeout)
3559

36-
public var httpClient: HTTPClientProtocol = {
37-
let configuration = HTTPClient.Configuration(timeout: timeout)
38-
return HTTPClient(eventLoopGroupProvider: .createNew, configuration: configuration)
39-
}()
40-
60+
/** The HTTPClientProtocol defines a generic httpClient
61+
62+
Required for Unit Testing
63+
*/
4164
public protocol HTTPClientProtocol: class {
4265
var eventLoopGroup: EventLoopGroup { get }
4366
func get(url: String, deadline: NIODeadline?) -> EventLoopFuture<HTTPClient.Response>
@@ -46,6 +69,16 @@ public protocol HTTPClientProtocol: class {
4669
func syncShutdown() throws
4770
}
4871

72+
73+
/** The httpClient implementing `HTTPClientProtocol`
74+
75+
The `default` implementation is an `HTTPClient` defined in `AsyncHTTPClient`
76+
*/
77+
public var httpClient: HTTPClientProtocol = {
78+
let configuration = HTTPClient.Configuration(timeout: timeout)
79+
return HTTPClient(eventLoopGroupProvider: .createNew, configuration: configuration)
80+
}()
81+
4982
extension HTTPClient: HTTPClientProtocol {
5083

5184
}

Sources/LambdaSwiftSprinterNioPlugin/NIOLambdaHandler.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import LambdaSwiftSprinter
2121
/**
2222
`SyncCodableNIOLambda<Event: Decodable, Response: Encodable>` lambda handler typealias.
2323

24-
- Usage example:
25-
24+
### Usage Example: ###
25+
2626
```
2727
import AsyncHTTPClient
2828
import Foundation
@@ -74,7 +74,7 @@ public typealias SyncCodableNIOLambda<Event: Decodable, Response: Encodable> = (
7474
/**
7575
`SyncDictionaryNIOLambda` lambda handler typealias.
7676

77-
- Usage example:
77+
### Usage Example: ###
7878

7979
```
8080
import AsyncHTTPClient
@@ -188,8 +188,7 @@ public typealias AsyncCodableNIOLambda<Event: Decodable, Response: Encodable> =
188188
/**
189189
`AsyncDictionaryNIOLambda` lambda handler typealias.
190190

191-
- Usage example:
192-
191+
### Usage Example: ###
193192
```
194193
import AsyncHTTPClient
195194
import Foundation

0 commit comments

Comments
 (0)