You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftAwsLambda/Lambda+Codable.swift
+90-32Lines changed: 90 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -19,88 +19,145 @@ import NIOFoundationCompat
19
19
/// Extension to the `Lambda` companion to enable execution of Lambdas that take and return `Codable` payloads.
20
20
/// This is the most common way to use this library in AWS Lambda, since its JSON based.
21
21
extensionLambda{
22
-
/// Run a Lambda defined by implementing the `LambdaCodableClosure` closure, having `In` and `Out` extending `Decodable` and `Encodable` respectively.
22
+
/// Run a Lambda defined by implementing the `CodableLambda.Closure` closure, having `In` and `Out` extending `Decodable` and `Encodable` respectively.
23
23
///
24
24
/// - note: This is a blocking operation that will run forever, as it's lifecycle is managed by the AWS Lambda Runtime Engine.
/// Default implementation for `CodableLambdaHandler` codec which uses JSON via `LambdaCodableJsonCodec`.
65
89
/// Advanced users that want to inject their own codec can do it by overriding this.
66
-
publicextensionLambdaCodableHandler{
90
+
publicextensionCodableLambdaHandler{
67
91
varcodec:LambdaCodableCodec<In,Out>{
68
-
returnLambdaCodableJsonCodec<In,Out>()
92
+
LambdaCodableJsonCodec<In,Out>()
69
93
}
70
94
}
71
95
72
-
/// LambdaCodableCodec is an abstract/empty implementation for codec which does `Encodable` -> `[UInt8]` encoding and `[UInt8]` -> `Decodable' decoding.
96
+
/// Default implementation for `CodableLambdaHandler` codec which uses JSON via `LambdaCodableJsonCodec`.
97
+
/// Advanced users that want to inject their own codec can do it by overriding this.
98
+
publicextensionCodablePromiseLambdaHandler{
99
+
varcodec:LambdaCodableCodec<In,Out>{
100
+
LambdaCodableJsonCodec<In,Out>()
101
+
}
102
+
}
103
+
104
+
/// LambdaCodableCodec is an abstract/empty implementation for codec which does `Encodable` -> `ByteBuffer` encoding and `ByteBuffer` -> `Decodable` decoding.
73
105
// TODO: would be nicer to use a protocol instead of this "abstract class", but generics get in the way
/// LambdaCodableJsonCodec is an implementation of `LambdaCodableCodec` which does `Encodable` -> `[UInt8]` encoding and `[UInt8]` -> `Decodable' decoding
137
+
/// Default implementation of `Encodable` -> `ByteBuffer` encoding and `ByteBuffer` -> `Decodable'`decoding
/// LambdaCodableJsonCodec is an implementation of `LambdaCodableCodec` which does `Encodable` -> `ByteBuffer` encoding and `ByteBuffer` -> `Decodable' decoding
104
161
/// using JSONEncoder and JSONDecoder respectively.
105
162
// This is a class as encoder amd decoder are a class, which means its cheaper to hold a reference to both in a class then a struct.
0 commit comments