@@ -22,22 +22,45 @@ import NIO
22
22
import NIOHTTP1
23
23
import NIOFoundationCompat
24
24
25
+ /**
26
+ `SprinterNIO` implements the AWS Lambda Custom Runtime with `SwiftNIO`
27
+ */
25
28
public typealias SprinterNIO = Sprinter < LambdaApiNIO >
26
29
30
+
31
+ /**
32
+ SprinterNIOError
33
+ An error related to the `SprinterNIO`
34
+
35
+ ### Errors: ###
36
+ ```
37
+ case invalidResponse(HTTPResponseStatus)
38
+ case invalidBuffer
39
+ ```
40
+ */
27
41
public enum SprinterNIOError : Error {
42
+
43
+ /// Invalid Reponse with `HTTPResponseStatus`
28
44
case invalidResponse( HTTPResponseStatus )
45
+
46
+ /// Invalid Buffer
29
47
case invalidBuffer
30
48
}
31
49
50
+ /** The amount of time the lambda waits for the next event.
51
+
52
+ The `default` timeout for a Lambda is `3600` seconds.
53
+ */
32
54
public var lambdaRuntimeTimeout : TimeAmount = . seconds( 3600 )
55
+
56
+ /// The timeout used to create the instance of the `httpClient`
33
57
public var timeout = HTTPClient . Configuration. Timeout ( connect: lambdaRuntimeTimeout,
34
58
read: lambdaRuntimeTimeout)
35
59
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
+ */
41
64
public protocol HTTPClientProtocol : class {
42
65
var eventLoopGroup : EventLoopGroup { get }
43
66
func get( url: String , deadline: NIODeadline ? ) -> EventLoopFuture < HTTPClient . Response >
@@ -46,6 +69,16 @@ public protocol HTTPClientProtocol: class {
46
69
func syncShutdown( ) throws
47
70
}
48
71
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
+
49
82
extension HTTPClient : HTTPClientProtocol {
50
83
51
84
}
0 commit comments