@@ -19,7 +19,7 @@ import NIOCore
19
19
// MARK: - LambdaHandler
20
20
21
21
#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.
23
23
@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
24
24
public protocol LambdaHandler : EventLoopLambdaHandler {
25
25
/// The Lambda initialization method
@@ -34,17 +34,17 @@ public protocol LambdaHandler: EventLoopLambdaHandler {
34
34
/// Concrete Lambda handlers implement this method to provide the Lambda functionality.
35
35
///
36
36
/// - parameters:
37
- /// - event: Event of type `In ` representing the event or request.
37
+ /// - event: Event of type `Event ` representing the event or request.
38
38
/// - context: Runtime `Context`.
39
39
///
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
42
42
}
43
43
44
44
@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
45
45
extension 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)
48
48
promise. completeWithTask {
49
49
try await self . handle ( event, context: context)
50
50
}
@@ -62,52 +62,52 @@ extension LambdaHandler {
62
62
63
63
// MARK: - EventLoopLambdaHandler
64
64
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.
67
67
///
68
68
/// - note: To implement a Lambda, implement either `LambdaHandler` or the `EventLoopLambdaHandler` protocol.
69
69
/// The `LambdaHandler` will offload the Lambda execution to a `DispatchQueue` making processing safer but slower
70
70
/// The `EventLoopLambdaHandler` will execute the Lambda on the same `EventLoop` as the core runtime engine, making the processing faster but requires
71
71
/// more care from the implementation to never block the `EventLoop`.
72
72
public protocol EventLoopLambdaHandler : ByteBufferLambdaHandler {
73
- associatedtype In
74
- associatedtype Out
73
+ associatedtype Event
74
+ associatedtype Output
75
75
76
76
/// The Lambda handling method
77
77
/// Concrete Lambda handlers implement this method to provide the Lambda functionality.
78
78
///
79
79
/// - parameters:
80
80
/// - 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.
82
82
///
83
83
/// - 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 >
86
86
87
- /// Encode a response of type `Out ` to `ByteBuffer`
87
+ /// Encode a response of type `Output ` to `ByteBuffer`
88
88
/// Concrete Lambda handlers implement this method to provide coding functionality.
89
89
/// - parameters:
90
90
/// - allocator: A `ByteBufferAllocator` to help allocate the `ByteBuffer`.
91
- /// - value: Response of type `Out `.
91
+ /// - value: Response of type `Output `.
92
92
///
93
93
/// - 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 ?
95
95
96
- /// Decode a`ByteBuffer` to a request or event of type `In `
96
+ /// Decode a`ByteBuffer` to a request or event of type `Event `
97
97
/// Concrete Lambda handlers implement this method to provide coding functionality.
98
98
///
99
99
/// - parameters:
100
100
/// - buffer: The `ByteBuffer` to decode.
101
101
///
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
104
104
}
105
105
106
106
extension EventLoopLambdaHandler {
107
- /// Driver for `ByteBuffer` -> `In ` decoding and `Out ` -> `ByteBuffer` encoding
107
+ /// Driver for `ByteBuffer` -> `Event ` decoding and `Output ` -> `ByteBuffer` encoding
108
108
@inlinable
109
109
public func handle( _ event: ByteBuffer , context: Lambda . Context ) -> EventLoopFuture < ByteBuffer ? > {
110
- let input : In
110
+ let input : Event
111
111
do {
112
112
input = try self . decode ( buffer: event)
113
113
} catch {
@@ -125,7 +125,7 @@ extension EventLoopLambdaHandler {
125
125
}
126
126
127
127
/// Implementation of `ByteBuffer` to `Void` decoding
128
- extension EventLoopLambdaHandler where Out == Void {
128
+ extension EventLoopLambdaHandler where Output == Void {
129
129
@inlinable
130
130
public func encode( allocator: ByteBufferAllocator , value: Void ) throws -> ByteBuffer ? {
131
131
nil
0 commit comments