Skip to content

Commit ddb7039

Browse files
authored
Remove old API (#355)
1 parent 7a8c0f2 commit ddb7039

31 files changed

+87
-4689
lines changed

Package.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ let package = Package(
8484
dependencies: [
8585
.byName(name: "AWSLambdaRuntime"),
8686
.product(name: "NIO", package: "swift-nio"),
87-
],
88-
swiftSettings: [.swiftLanguageMode(.v5)]
87+
]
8988
),
9089
.testTarget(
9190
name: "AWSLambdaTestingTests",
92-
dependencies: ["AWSLambdaTesting"],
93-
swiftSettings: [.swiftLanguageMode(.v5)]
91+
dependencies: [
92+
.byName(name: "AWSLambdaTesting"),
93+
.product(name: "Testing", package: "swift-testing"),
94+
]
9495
),
9596
// for perf testing
9697
.executableTarget(

Sources/AWSLambdaRuntime/Context+Foundation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import AWSLambdaRuntimeCore
1616

1717
import struct Foundation.Date
1818

19-
extension LambdaContext {
19+
extension NewLambdaContext {
2020
var deadlineDate: Date {
2121
let secondsSinceEpoch = Double(Int64(bitPattern: self.deadline.rawValue)) / -1_000_000_000
2222
return Date(timeIntervalSince1970: secondsSinceEpoch)

Sources/AWSLambdaRuntime/Lambda+Codable.swift

-119
Original file line numberDiff line numberDiff line change
@@ -24,125 +24,6 @@ import class Foundation.JSONDecoder
2424
import class Foundation.JSONEncoder
2525
#endif
2626

27-
// MARK: - SimpleLambdaHandler Codable support
28-
29-
/// Implementation of `ByteBuffer` to `Event` decoding.
30-
extension SimpleLambdaHandler where Event: Decodable {
31-
@inlinable
32-
public func decode(buffer: ByteBuffer) throws -> Event {
33-
try self.decoder.decode(Event.self, from: buffer)
34-
}
35-
}
36-
37-
/// Implementation of `Output` to `ByteBuffer` encoding.
38-
extension SimpleLambdaHandler where Output: Encodable {
39-
@inlinable
40-
public func encode(value: Output, into buffer: inout ByteBuffer) throws {
41-
try self.encoder.encode(value, into: &buffer)
42-
}
43-
}
44-
45-
/// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
46-
/// Advanced users who want to inject their own codec can do it by overriding these functions.
47-
extension SimpleLambdaHandler where Event: Decodable {
48-
public var decoder: LambdaCodableDecoder {
49-
Lambda.defaultJSONDecoder
50-
}
51-
}
52-
53-
/// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
54-
/// Advanced users who want to inject their own codec can do it by overriding these functions.
55-
extension SimpleLambdaHandler where Output: Encodable {
56-
public var encoder: LambdaCodableEncoder {
57-
Lambda.defaultJSONEncoder
58-
}
59-
}
60-
61-
// MARK: - LambdaHandler Codable support
62-
63-
/// Implementation of `ByteBuffer` to `Event` decoding.
64-
extension LambdaHandler where Event: Decodable {
65-
@inlinable
66-
public func decode(buffer: ByteBuffer) throws -> Event {
67-
try self.decoder.decode(Event.self, from: buffer)
68-
}
69-
}
70-
71-
/// Implementation of `Output` to `ByteBuffer` encoding.
72-
extension LambdaHandler where Output: Encodable {
73-
@inlinable
74-
public func encode(value: Output, into buffer: inout ByteBuffer) throws {
75-
try self.encoder.encode(value, into: &buffer)
76-
}
77-
}
78-
79-
/// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
80-
/// Advanced users who want to inject their own codec can do it by overriding these functions.
81-
extension LambdaHandler where Event: Decodable {
82-
public var decoder: LambdaCodableDecoder {
83-
Lambda.defaultJSONDecoder
84-
}
85-
}
86-
87-
/// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
88-
/// Advanced users who want to inject their own codec can do it by overriding these functions.
89-
extension LambdaHandler where Output: Encodable {
90-
public var encoder: LambdaCodableEncoder {
91-
Lambda.defaultJSONEncoder
92-
}
93-
}
94-
95-
// MARK: - EventLoopLambdaHandler Codable support
96-
97-
/// Implementation of `ByteBuffer` to `Event` decoding.
98-
extension EventLoopLambdaHandler where Event: Decodable {
99-
@inlinable
100-
public func decode(buffer: ByteBuffer) throws -> Event {
101-
try self.decoder.decode(Event.self, from: buffer)
102-
}
103-
}
104-
105-
/// Implementation of `Output` to `ByteBuffer` encoding.
106-
extension EventLoopLambdaHandler where Output: Encodable {
107-
@inlinable
108-
public func encode(value: Output, into buffer: inout ByteBuffer) throws {
109-
try self.encoder.encode(value, into: &buffer)
110-
}
111-
}
112-
113-
/// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
114-
/// Advanced users that want to inject their own codec can do it by overriding these functions.
115-
extension EventLoopLambdaHandler where Event: Decodable {
116-
public var decoder: LambdaCodableDecoder {
117-
Lambda.defaultJSONDecoder
118-
}
119-
}
120-
121-
/// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
122-
/// Advanced users that want to inject their own codec can do it by overriding these functions.
123-
extension EventLoopLambdaHandler where Output: Encodable {
124-
public var encoder: LambdaCodableEncoder {
125-
Lambda.defaultJSONEncoder
126-
}
127-
}
128-
129-
public protocol LambdaCodableDecoder {
130-
func decode<T: Decodable>(_ type: T.Type, from buffer: ByteBuffer) throws -> T
131-
}
132-
133-
public protocol LambdaCodableEncoder {
134-
func encode<T: Encodable>(_ value: T, into buffer: inout ByteBuffer) throws
135-
}
136-
137-
extension Lambda {
138-
fileprivate static let defaultJSONDecoder = JSONDecoder()
139-
fileprivate static let defaultJSONEncoder = JSONEncoder()
140-
}
141-
142-
extension JSONDecoder: LambdaCodableDecoder {}
143-
144-
extension JSONEncoder: LambdaCodableEncoder {}
145-
14627
extension JSONDecoder: AWSLambdaRuntimeCore.LambdaEventDecoder {}
14728

14829
@usableFromInline

Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ package struct InvocationMetadata: Hashable {
3636
package let clientContext: String?
3737
package let cognitoIdentity: String?
3838

39-
package init(headers: HTTPHeaders) throws {
39+
package init(headers: HTTPHeaders) throws(NewLambdaRuntimeError) {
4040
guard let requestID = headers.first(name: AmazonHeaders.requestID), !requestID.isEmpty else {
41-
throw LambdaRuntimeError.invocationMissingHeader(AmazonHeaders.requestID)
41+
throw NewLambdaRuntimeError(code: .nextInvocationMissingHeaderRequestID)
4242
}
4343

4444
guard let deadline = headers.first(name: AmazonHeaders.deadline),
4545
let unixTimeInMilliseconds = Int64(deadline)
4646
else {
47-
throw LambdaRuntimeError.invocationMissingHeader(AmazonHeaders.deadline)
47+
throw NewLambdaRuntimeError(code: .nextInvocationMissingHeaderDeadline)
4848
}
4949

5050
guard let invokedFunctionARN = headers.first(name: AmazonHeaders.invokedFunctionARN) else {
51-
throw LambdaRuntimeError.invocationMissingHeader(AmazonHeaders.invokedFunctionARN)
51+
throw NewLambdaRuntimeError(code: .nextInvocationMissingHeaderInvokeFuctionARN)
5252
}
5353

5454
self.requestID = requestID

Sources/AWSLambdaRuntimeCore/DetachedTasks.swift

-94
This file was deleted.

0 commit comments

Comments
 (0)