@@ -32,11 +32,22 @@ public var lambdaRuntimeTimeout: TimeAmount = .seconds(3600)
32
32
public var timeout = HTTPClient . Configuration. Timeout ( connect: lambdaRuntimeTimeout,
33
33
read: lambdaRuntimeTimeout)
34
34
35
- public var httpClient : HTTPClient = {
35
+ public var httpClient : HTTPClientProtocol = {
36
36
let configuration = HTTPClient . Configuration ( timeout: timeout)
37
37
return HTTPClient ( eventLoopGroupProvider: . createNew, configuration: configuration)
38
38
} ( )
39
39
40
+ public protocol HTTPClientProtocol : class {
41
+ func get( url: String , deadline: NIODeadline ? ) -> EventLoopFuture < HTTPClient . Response >
42
+ func post( url: String , body: HTTPClient . Body ? , deadline: NIODeadline ? ) -> EventLoopFuture < HTTPClient . Response >
43
+ func execute( request: HTTPClient . Request , deadline: NIODeadline ? ) -> EventLoopFuture < HTTPClient . Response >
44
+ func syncShutdown( ) throws
45
+ }
46
+
47
+ extension HTTPClient : HTTPClientProtocol {
48
+
49
+ }
50
+
40
51
public class LambdaApiNIO : LambdaAPI {
41
52
let urlBuilder : LambdaRuntimeAPIUrlBuilder
42
53
@@ -47,7 +58,8 @@ public class LambdaApiNIO: LambdaAPI {
47
58
public func getNextInvocation( ) throws -> ( event: Data , responseHeaders: [ AnyHashable : Any ] ) {
48
59
let request = try HTTPClient . Request ( url: urlBuilder. nextInvocationURL ( ) , method: . GET)
49
60
let result = try httpClient. execute (
50
- request: request
61
+ request: request,
62
+ deadline: nil
51
63
) . wait ( )
52
64
53
65
let httpHeaders = result. headers
@@ -72,7 +84,8 @@ public class LambdaApiNIO: LambdaAPI {
72
84
)
73
85
request. body = . data( httpBody)
74
86
_ = try httpClient. execute (
75
- request: request
87
+ request: request,
88
+ deadline: nil
76
89
) . wait ( )
77
90
}
78
91
@@ -87,7 +100,8 @@ public class LambdaApiNIO: LambdaAPI {
87
100
request. body = . data( httpBody)
88
101
89
102
_ = try httpClient. execute (
90
- request: request
103
+ request: request,
104
+ deadline: nil
91
105
) . wait ( )
92
106
}
93
107
@@ -102,7 +116,8 @@ public class LambdaApiNIO: LambdaAPI {
102
116
request. body = . data( httpBody)
103
117
104
118
_ = try httpClient. execute (
105
- request: request
119
+ request: request,
120
+ deadline: nil
106
121
) . wait ( )
107
122
}
108
123
}
0 commit comments