Skip to content

Commit 5104f27

Browse files
committed
Rename In to Event and Out to Output
1 parent 501bc6e commit 5104f27

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

Sources/AWSLambdaRuntime/Lambda+Codable.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ import NIOFoundationCompat
2121

2222
// MARK: - Codable support
2323

24-
/// Implementation of a`ByteBuffer` to `In` decoding
25-
extension EventLoopLambdaHandler where In: Decodable {
24+
/// Implementation of a`ByteBuffer` to `Event` decoding
25+
extension EventLoopLambdaHandler where Event: Decodable {
2626
@inlinable
27-
public func decode(buffer: ByteBuffer) throws -> In {
28-
try self.decoder.decode(In.self, from: buffer)
27+
public func decode(buffer: ByteBuffer) throws -> Event {
28+
try self.decoder.decode(Event.self, from: buffer)
2929
}
3030
}
3131

32-
/// Implementation of `Out` to `ByteBuffer` encoding
33-
extension EventLoopLambdaHandler where Out: Encodable {
32+
/// Implementation of `Output` to `ByteBuffer` encoding
33+
extension EventLoopLambdaHandler where Output: Encodable {
3434
@inlinable
35-
public func encode(allocator: ByteBufferAllocator, value: Out) throws -> ByteBuffer? {
35+
public func encode(allocator: ByteBufferAllocator, value: Output) throws -> ByteBuffer? {
3636
try self.encoder.encode(value, using: allocator)
3737
}
3838
}
3939

40-
/// Default `ByteBuffer` to `In` decoder using Foundation's JSONDecoder
40+
/// Default `ByteBuffer` to `Event` decoder using Foundation's JSONDecoder
4141
/// Advanced users that want to inject their own codec can do it by overriding these functions.
42-
extension EventLoopLambdaHandler where In: Decodable {
42+
extension EventLoopLambdaHandler where Event: Decodable {
4343
public var decoder: LambdaCodableDecoder {
4444
Lambda.defaultJSONDecoder
4545
}
4646
}
4747

48-
/// Default `Out` to `ByteBuffer` encoder using Foundation's JSONEncoder
48+
/// Default `Output` to `ByteBuffer` encoder using Foundation's JSONEncoder
4949
/// Advanced users that want to inject their own codec can do it by overriding these functions.
50-
extension EventLoopLambdaHandler where Out: Encodable {
50+
extension EventLoopLambdaHandler where Output: Encodable {
5151
public var encoder: LambdaCodableEncoder {
5252
Lambda.defaultJSONEncoder
5353
}

Sources/AWSLambdaRuntimeCore/Lambda+String.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414
import NIOCore
1515

16-
extension EventLoopLambdaHandler where In == String {
16+
extension EventLoopLambdaHandler where Event == String {
1717
/// Implementation of a `ByteBuffer` to `String` decoding
1818
@inlinable
1919
public func decode(buffer: ByteBuffer) throws -> String {
@@ -25,7 +25,7 @@ extension EventLoopLambdaHandler where In == String {
2525
}
2626
}
2727

28-
extension EventLoopLambdaHandler where Out == String {
28+
extension EventLoopLambdaHandler where Output == String {
2929
/// Implementation of `String` to `ByteBuffer` encoding
3030
@inlinable
3131
public func encode(allocator: ByteBufferAllocator, value: String) throws -> ByteBuffer? {

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

+22-22
Original file line numberDiff line numberDiff line change
@@ -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, *)
2424
public protocol LambdaHandler: EventLoopLambdaHandler {
2525
/// The Lambda initialization method
@@ -34,17 +34,17 @@ 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, *)
4545
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)
4848
promise.completeWithTask {
4949
try await self.handle(event, context: context)
5050
}
@@ -62,52 +62,52 @@ 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`.
7272
public 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

106106
extension EventLoopLambdaHandler {
107-
/// Driver for `ByteBuffer` -> `In` decoding and `Out` -> `ByteBuffer` encoding
107+
/// Driver for `ByteBuffer` -> `Event` decoding and `Output` -> `ByteBuffer` encoding
108108
@inlinable
109109
public func handle(_ event: ByteBuffer, context: Lambda.Context) -> EventLoopFuture<ByteBuffer?> {
110-
let input: In
110+
let input: Event
111111
do {
112112
input = try self.decode(buffer: event)
113113
} 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

Sources/StringSample/main.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import NIOCore
1717

1818
// in this example we are receiving and responding with strings
1919
struct Handler: EventLoopLambdaHandler {
20-
typealias In = String
21-
typealias Out = String
20+
typealias Event = String
21+
typealias Output = String
2222

2323
func handle(_ event: String, context: Lambda.Context) -> EventLoopFuture<String> {
2424
// as an example, respond with the event's reversed body

Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class CodableLambdaTest: XCTestCase {
3838
var outputBuffer: ByteBuffer?
3939

4040
struct Handler: EventLoopLambdaHandler {
41-
typealias In = Request
42-
typealias Out = Void
41+
typealias Event = Request
42+
typealias Output = Void
4343

4444
let expected: Request
4545

@@ -63,8 +63,8 @@ class CodableLambdaTest: XCTestCase {
6363
var response: Response?
6464

6565
struct Handler: EventLoopLambdaHandler {
66-
typealias In = Request
67-
typealias Out = Response
66+
typealias Event = Request
67+
typealias Output = Response
6868

6969
let expected: Request
7070

@@ -86,8 +86,8 @@ class CodableLambdaTest: XCTestCase {
8686
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
8787
func testCodableVoidHandler() {
8888
struct Handler: LambdaHandler {
89-
typealias In = Request
90-
typealias Out = Void
89+
typealias Event = Request
90+
typealias Output = Void
9191

9292
var expected: Request?
9393

@@ -115,8 +115,8 @@ class CodableLambdaTest: XCTestCase {
115115
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
116116
func testCodableHandler() {
117117
struct Handler: LambdaHandler {
118-
typealias In = Request
119-
typealias Out = Response
118+
typealias Event = Request
119+
typealias Output = Response
120120

121121
var expected: Request?
122122

0 commit comments

Comments
 (0)