@@ -19,7 +19,7 @@ import NIOCore
1919// MARK: - LambdaHandler
2020
2121#if compiler(>=5.5)
22- /// Strongly typed, processing protocol for a Lambda that takes a user defined `In ` and returns a user defined `Out ` async.
22+ /// Strongly typed, processing protocol for a Lambda that takes a user defined `Event ` and returns a user defined `Output ` async.
2323@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
2424public protocol LambdaHandler : EventLoopLambdaHandler {
2525 /// The Lambda initialization method
@@ -34,19 +34,19 @@ public protocol LambdaHandler: EventLoopLambdaHandler {
3434 /// Concrete Lambda handlers implement this method to provide the Lambda functionality.
3535 ///
3636 /// - parameters:
37- /// - event: Event of type `In ` representing the event or request.
37+ /// - event: Event of type `Event ` representing the event or request.
3838 /// - context: Runtime `Context`.
3939 ///
40- /// - Returns: A Lambda result ot type `Out `.
41- func handle( event: In , context: Lambda . Context ) async throws -> Out
40+ /// - Returns: A Lambda result ot type `Output `.
41+ func handle( _ event: Event , context: Lambda . Context ) async throws -> Output
4242}
4343
4444@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
4545extension LambdaHandler {
46- public func handle( event: In , context: Lambda . Context ) -> EventLoopFuture < Out > {
47- let promise = context. eventLoop. makePromise ( of: Out . self)
46+ public func handle( _ event: Event , context: Lambda . Context ) -> EventLoopFuture < Output > {
47+ let promise = context. eventLoop. makePromise ( of: Output . self)
4848 promise. completeWithTask {
49- try await self . handle ( event: event , context: context)
49+ try await self . handle ( event, context: context)
5050 }
5151 return promise. futureResult
5252 }
@@ -62,59 +62,59 @@ extension LambdaHandler {
6262
6363// MARK: - EventLoopLambdaHandler
6464
65- /// Strongly typed, `EventLoopFuture` based processing protocol for a Lambda that takes a user defined `In ` and returns a user defined `Out ` asynchronously.
66- /// `EventLoopLambdaHandler` extends `ByteBufferLambdaHandler`, performing `ByteBuffer` -> `In ` decoding and `Out ` -> `ByteBuffer` encoding.
65+ /// Strongly typed, `EventLoopFuture` based processing protocol for a Lambda that takes a user defined `Event ` and returns a user defined `Output ` asynchronously.
66+ /// `EventLoopLambdaHandler` extends `ByteBufferLambdaHandler`, performing `ByteBuffer` -> `Event ` decoding and `Output ` -> `ByteBuffer` encoding.
6767///
6868/// - note: To implement a Lambda, implement either `LambdaHandler` or the `EventLoopLambdaHandler` protocol.
6969/// The `LambdaHandler` will offload the Lambda execution to a `DispatchQueue` making processing safer but slower
7070/// The `EventLoopLambdaHandler` will execute the Lambda on the same `EventLoop` as the core runtime engine, making the processing faster but requires
7171/// more care from the implementation to never block the `EventLoop`.
7272public protocol EventLoopLambdaHandler : ByteBufferLambdaHandler {
73- associatedtype In
74- associatedtype Out
73+ associatedtype Event
74+ associatedtype Output
7575
7676 /// The Lambda handling method
7777 /// Concrete Lambda handlers implement this method to provide the Lambda functionality.
7878 ///
7979 /// - parameters:
8080 /// - context: Runtime `Context`.
81- /// - event: Event of type `In ` representing the event or request.
81+ /// - event: Event of type `Event ` representing the event or request.
8282 ///
8383 /// - Returns: An `EventLoopFuture` to report the result of the Lambda back to the runtime engine.
84- /// The `EventLoopFuture` should be completed with either a response of type `Out ` or an `Error`
85- func handle( event: In , context: Lambda . Context ) -> EventLoopFuture < Out >
84+ /// The `EventLoopFuture` should be completed with either a response of type `Output ` or an `Error`
85+ func handle( _ event: Event , context: Lambda . Context ) -> EventLoopFuture < Output >
8686
87- /// Encode a response of type `Out ` to `ByteBuffer`
87+ /// Encode a response of type `Output ` to `ByteBuffer`
8888 /// Concrete Lambda handlers implement this method to provide coding functionality.
8989 /// - parameters:
9090 /// - allocator: A `ByteBufferAllocator` to help allocate the `ByteBuffer`.
91- /// - value: Response of type `Out `.
91+ /// - value: Response of type `Output `.
9292 ///
9393 /// - Returns: A `ByteBuffer` with the encoded version of the `value`.
94- func encode( allocator: ByteBufferAllocator , value: Out ) throws -> ByteBuffer ?
94+ func encode( allocator: ByteBufferAllocator , value: Output ) throws -> ByteBuffer ?
9595
96- /// Decode a`ByteBuffer` to a request or event of type `In `
96+ /// Decode a`ByteBuffer` to a request or event of type `Event `
9797 /// Concrete Lambda handlers implement this method to provide coding functionality.
9898 ///
9999 /// - parameters:
100100 /// - buffer: The `ByteBuffer` to decode.
101101 ///
102- /// - Returns: A request or event of type `In `.
103- func decode( buffer: ByteBuffer ) throws -> In
102+ /// - Returns: A request or event of type `Event `.
103+ func decode( buffer: ByteBuffer ) throws -> Event
104104}
105105
106106extension EventLoopLambdaHandler {
107- /// Driver for `ByteBuffer` -> `In ` decoding and `Out ` -> `ByteBuffer` encoding
107+ /// Driver for `ByteBuffer` -> `Event ` decoding and `Output ` -> `ByteBuffer` encoding
108108 @inlinable
109- public func handle( event: ByteBuffer , context: Lambda . Context ) -> EventLoopFuture < ByteBuffer ? > {
110- let input : In
109+ public func handle( _ event: ByteBuffer , context: Lambda . Context ) -> EventLoopFuture < ByteBuffer ? > {
110+ let input : Event
111111 do {
112112 input = try self . decode ( buffer: event)
113113 } catch {
114114 return context. eventLoop. makeFailedFuture ( CodecError . requestDecoding ( error) )
115115 }
116116
117- return self . handle ( event : input, context: context) . flatMapThrowing { output in
117+ return self . handle ( input, context: context) . flatMapThrowing { output in
118118 do {
119119 return try self . encode ( allocator: context. allocator, value: output)
120120 } catch {
@@ -125,7 +125,7 @@ extension EventLoopLambdaHandler {
125125}
126126
127127/// Implementation of `ByteBuffer` to `Void` decoding
128- extension EventLoopLambdaHandler where Out == Void {
128+ extension EventLoopLambdaHandler where Output == Void {
129129 @inlinable
130130 public func encode( allocator: ByteBufferAllocator , value: Void ) throws -> ByteBuffer ? {
131131 nil
@@ -148,7 +148,7 @@ public protocol ByteBufferLambdaHandler {
148148 ///
149149 /// - Returns: An `EventLoopFuture` to report the result of the Lambda back to the runtime engine.
150150 /// The `EventLoopFuture` should be completed with either a response encoded as `ByteBuffer` or an `Error`
151- func handle( event: ByteBuffer , context: Lambda . Context ) -> EventLoopFuture < ByteBuffer ? >
151+ func handle( _ event: ByteBuffer , context: Lambda . Context ) -> EventLoopFuture < ByteBuffer ? >
152152
153153 /// Clean up the Lambda resources asynchronously.
154154 /// Concrete Lambda handlers implement this method to shutdown resources like `HTTPClient`s and database connections.
0 commit comments