@@ -21,12 +21,14 @@ extension Lambda {
21
21
internal final class Runner {
22
22
private let runtimeClient : RuntimeClient
23
23
private let eventLoop : EventLoop
24
+ private let allocator : ByteBufferAllocator
24
25
25
26
private var isGettingNextInvocation = false
26
27
27
28
init ( eventLoop: EventLoop , configuration: Configuration ) {
28
29
self . eventLoop = eventLoop
29
30
self . runtimeClient = RuntimeClient ( eventLoop: self . eventLoop, configuration: configuration. runtimeEngine)
31
+ self . allocator = ByteBufferAllocator ( )
30
32
}
31
33
32
34
/// Run the user provided initializer. This *must* only be called once.
@@ -36,7 +38,9 @@ extension Lambda {
36
38
logger. debug ( " initializing lambda " )
37
39
// 1. create the handler from the factory
38
40
// 2. report initialization error if one occured
39
- let context = InitializationContext ( logger: logger, eventLoop: self . eventLoop)
41
+ let context = InitializationContext ( logger: logger,
42
+ eventLoop: self . eventLoop,
43
+ allocator: self . allocator)
40
44
return factory ( context)
41
45
// Hopping back to "our" EventLoop is importnant in case the factory returns a future
42
46
// that originated from a foreign EventLoop/EventLoopGroup.
@@ -61,7 +65,10 @@ extension Lambda {
61
65
} . flatMap { invocation, event in
62
66
// 2. send invocation to handler
63
67
self . isGettingNextInvocation = false
64
- let context = Context ( logger: logger, eventLoop: self . eventLoop, invocation: invocation)
68
+ let context = Context ( logger: logger,
69
+ eventLoop: self . eventLoop,
70
+ allocator: self . allocator,
71
+ invocation: invocation)
65
72
logger. debug ( " sending invocation to lambda handler \( handler) " )
66
73
return handler. handle ( context: context, event: event)
67
74
// Hopping back to "our" EventLoop is importnant in case the handler returns a future that
@@ -94,15 +101,16 @@ extension Lambda {
94
101
}
95
102
96
103
private extension Lambda . Context {
97
- convenience init ( logger: Logger , eventLoop: EventLoop , invocation: Lambda . Invocation ) {
104
+ convenience init ( logger: Logger , eventLoop: EventLoop , allocator : ByteBufferAllocator , invocation: Lambda . Invocation ) {
98
105
self . init ( requestID: invocation. requestID,
99
106
traceID: invocation. traceID,
100
107
invokedFunctionARN: invocation. invokedFunctionARN,
101
108
deadline: DispatchWallTime ( millisSinceEpoch: invocation. deadlineInMillisSinceEpoch) ,
102
109
cognitoIdentity: invocation. cognitoIdentity,
103
110
clientContext: invocation. clientContext,
104
111
logger: logger,
105
- eventLoop: eventLoop)
112
+ eventLoop: eventLoop,
113
+ allocator: allocator)
106
114
}
107
115
}
108
116
0 commit comments