@@ -39,20 +39,20 @@ public protocol LambdaHandler: EventLoopLambdaHandler {
39
39
func handle( context: Lambda . Context , event: In , callback: @escaping ( Result < Out , Error > ) -> Void )
40
40
}
41
41
42
- internal extension Lambda {
43
- static let defaultOffloadQueue = DispatchQueue ( label: " LambdaHandler.offload " )
42
+ extension Lambda {
43
+ internal static let defaultOffloadQueue = DispatchQueue ( label: " LambdaHandler.offload " )
44
44
}
45
45
46
- public extension LambdaHandler {
46
+ extension LambdaHandler {
47
47
/// The queue on which `handle` is invoked on.
48
- var offloadQueue : DispatchQueue {
48
+ public var offloadQueue : DispatchQueue {
49
49
Lambda . defaultOffloadQueue
50
50
}
51
51
52
52
/// `LambdaHandler` is offloading the processing to a `DispatchQueue`
53
53
/// This is slower but safer, in case the implementation blocks the `EventLoop`
54
54
/// Performance sensitive Lambdas should be based on `EventLoopLambdaHandler` which does not offload.
55
- func handle( context: Lambda . Context , event: In ) -> EventLoopFuture < Out > {
55
+ public func handle( context: Lambda . Context , event: In ) -> EventLoopFuture < Out > {
56
56
let promise = context. eventLoop. makePromise ( of: Out . self)
57
57
// FIXME: reusable DispatchQueue
58
58
self . offloadQueue. async {
@@ -62,8 +62,8 @@ public extension LambdaHandler {
62
62
}
63
63
}
64
64
65
- public extension LambdaHandler {
66
- func shutdown( context: Lambda . ShutdownContext ) -> EventLoopFuture < Void > {
65
+ extension LambdaHandler {
66
+ public func shutdown( context: Lambda . ShutdownContext ) -> EventLoopFuture < Void > {
67
67
let promise = context. eventLoop. makePromise ( of: Void . self)
68
68
self . offloadQueue. async {
69
69
do {
@@ -78,7 +78,7 @@ public extension LambdaHandler {
78
78
79
79
/// Clean up the Lambda resources synchronously.
80
80
/// Concrete Lambda handlers implement this method to shutdown resources like `HTTPClient`s and database connections.
81
- func syncShutdown( context: Lambda . ShutdownContext ) throws {
81
+ public func syncShutdown( context: Lambda . ShutdownContext ) throws {
82
82
// noop
83
83
}
84
84
}
@@ -126,9 +126,9 @@ public protocol EventLoopLambdaHandler: ByteBufferLambdaHandler {
126
126
func decode( buffer: ByteBuffer ) throws -> In
127
127
}
128
128
129
- public extension EventLoopLambdaHandler {
129
+ extension EventLoopLambdaHandler {
130
130
/// Driver for `ByteBuffer` -> `In` decoding and `Out` -> `ByteBuffer` encoding
131
- func handle( context: Lambda . Context , event: ByteBuffer ) -> EventLoopFuture < ByteBuffer ? > {
131
+ public func handle( context: Lambda . Context , event: ByteBuffer ) -> EventLoopFuture < ByteBuffer ? > {
132
132
switch self . decodeIn ( buffer: event) {
133
133
case . failure( let error) :
134
134
return context. eventLoop. makeFailedFuture ( CodecError . requestDecoding ( error) )
@@ -162,8 +162,8 @@ public extension EventLoopLambdaHandler {
162
162
}
163
163
164
164
/// Implementation of `ByteBuffer` to `Void` decoding
165
- public extension EventLoopLambdaHandler where Out == Void {
166
- func encode( allocator: ByteBufferAllocator , value: Void ) throws -> ByteBuffer ? {
165
+ extension EventLoopLambdaHandler where Out == Void {
166
+ public func encode( allocator: ByteBufferAllocator , value: Void ) throws -> ByteBuffer ? {
167
167
nil
168
168
}
169
169
}
@@ -194,8 +194,8 @@ public protocol ByteBufferLambdaHandler {
194
194
func shutdown( context: Lambda . ShutdownContext ) -> EventLoopFuture < Void >
195
195
}
196
196
197
- public extension ByteBufferLambdaHandler {
198
- func shutdown( context: Lambda . ShutdownContext ) -> EventLoopFuture < Void > {
197
+ extension ByteBufferLambdaHandler {
198
+ public func shutdown( context: Lambda . ShutdownContext ) -> EventLoopFuture < Void > {
199
199
context. eventLoop. makeSucceededFuture ( ( ) )
200
200
}
201
201
}
0 commit comments