Skip to content

Commit 2a118fb

Browse files
authored
Add Sendable support (#15)
1 parent f1936ce commit 2a118fb

File tree

14 files changed

+127
-13
lines changed

14 files changed

+127
-13
lines changed

Sources/AWSLambdaEvents/ALB.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -73,3 +73,10 @@ public struct ALBTargetGroupResponse: Codable {
7373
self.isBase64Encoded = isBase64Encoded
7474
}
7575
}
76+
77+
#if swift(>=5.6)
78+
extension ALBTargetGroupRequest: Sendable {}
79+
extension ALBTargetGroupRequest.Context: Sendable {}
80+
extension ALBTargetGroupRequest.ELBContext: Sendable {}
81+
extension ALBTargetGroupResponse: Sendable {}
82+
#endif

Sources/AWSLambdaEvents/APIGateway+V2.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -106,3 +106,12 @@ public struct APIGatewayV2Response: Codable {
106106
self.cookies = cookies
107107
}
108108
}
109+
110+
#if swift(>=5.6)
111+
extension APIGatewayV2Request: Sendable {}
112+
extension APIGatewayV2Request.Context: Sendable {}
113+
extension APIGatewayV2Request.Context.HTTP: Sendable {}
114+
extension APIGatewayV2Request.Context.Authorizer: Sendable {}
115+
extension APIGatewayV2Request.Context.Authorizer.JWT: Sendable {}
116+
extension APIGatewayV2Response: Sendable {}
117+
#endif

Sources/AWSLambdaEvents/APIGateway.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -87,3 +87,10 @@ public struct APIGatewayResponse: Codable {
8787
self.isBase64Encoded = isBase64Encoded
8888
}
8989
}
90+
91+
#if swift(>=5.6)
92+
extension APIGatewayRequest: Sendable {}
93+
extension APIGatewayRequest.Context: Sendable {}
94+
extension APIGatewayRequest.Context.Identity: Sendable {}
95+
extension APIGatewayResponse: Sendable {}
96+
#endif

Sources/AWSLambdaEvents/AWSRegion.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -90,3 +90,7 @@ extension AWSRegion: Codable {
9090
try container.encode(self.rawValue)
9191
}
9292
}
93+
94+
#if swift(>=5.6)
95+
extension AWSRegion: Sendable {}
96+
#endif

Sources/AWSLambdaEvents/AppSync.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -163,3 +163,14 @@ public enum AppSyncResponse<ResultType: Encodable>: Encodable {
163163
}
164164

165165
public typealias AppSyncJSONResponse = AppSyncResponse<String>
166+
167+
#if swift(>=5.6)
168+
extension AppSyncEvent: Sendable {}
169+
extension AppSyncEvent.ArgumentValue: Sendable {}
170+
extension AppSyncEvent.Request: Sendable {}
171+
extension AppSyncEvent.Info: Sendable {}
172+
extension AppSyncEvent.Identity: Sendable {}
173+
extension AppSyncEvent.Identity.CognitoUserPoolIdentity: Sendable {}
174+
extension AppSyncEvent.Identity.IAMIdentity: Sendable {}
175+
extension AppSyncResponse: Sendable where ResultType: Sendable {}
176+
#endif

Sources/AWSLambdaEvents/Cloudwatch.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,7 +12,11 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if swift(>=5.6)
16+
@preconcurrency import struct Foundation.Date
17+
#else
1518
import struct Foundation.Date
19+
#endif
1620

1721
/// EventBridge has the same events/notification types as CloudWatch
1822
typealias EventBridgeEvent = CloudwatchEvent
@@ -130,3 +134,9 @@ public enum CloudwatchDetails {
130134
let type: Any
131135
}
132136
}
137+
138+
#if swift(>=5.6)
139+
extension CloudwatchEvent: Sendable where Detail: Sendable {}
140+
extension CloudwatchDetails.EC2: Sendable {}
141+
extension CloudwatchDetails.Scheduled: Sendable {}
142+
#endif

Sources/AWSLambdaEvents/DynamoDB.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,7 +12,11 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if swift(>=5.6)
16+
@preconcurrency import struct Foundation.Date
17+
#else
1518
import struct Foundation.Date
19+
#endif
1620

1721
// https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html
1822
public struct DynamoDBEvent: Decodable {
@@ -930,3 +934,13 @@ extension DynamoDBEvent.AttributeValue {
930934
}
931935
}
932936
}
937+
938+
#if swift(>=5.6)
939+
extension DynamoDBEvent: Sendable {}
940+
extension DynamoDBEvent.EventRecord: Sendable {}
941+
extension DynamoDBEvent.StreamRecord: Sendable {}
942+
extension DynamoDBEvent.UserIdentity: Sendable {}
943+
extension DynamoDBEvent.OperationType: Sendable {}
944+
extension DynamoDBEvent.AttributeValue: Sendable {}
945+
extension DynamoDBEvent.StreamViewType: Sendable {}
946+
#endif

Sources/AWSLambdaEvents/S3.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -77,3 +77,13 @@ public struct S3Event: Decodable {
7777
public let sequencer: String
7878
}
7979
}
80+
81+
#if swift(>=5.6)
82+
extension S3Event: Sendable {}
83+
extension S3Event.Bucket: Sendable {}
84+
extension S3Event.Entity: Sendable {}
85+
extension S3Event.Object: Sendable {}
86+
extension S3Event.Record: Sendable {}
87+
extension S3Event.RequestParameters: Sendable {}
88+
extension S3Event.UserIdentity: Sendable {}
89+
#endif

Sources/AWSLambdaEvents/SES.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -96,3 +96,17 @@ public struct SESEvent: Decodable {
9696
case processingFailed = "PROCESSING_FAILED"
9797
}
9898
}
99+
100+
#if swift(>=5.6)
101+
extension SESEvent: Sendable {}
102+
extension SESEvent.Record: Sendable {}
103+
extension SESEvent.Message: Sendable {}
104+
extension SESEvent.Mail: Sendable {}
105+
extension SESEvent.Receipt: Sendable {}
106+
extension SESEvent.CommonHeaders: Sendable {}
107+
extension SESEvent.Action: Sendable {}
108+
extension SESEvent.Header: Sendable {}
109+
extension SESEvent.DMARCPolicy: Sendable {}
110+
extension SESEvent.Verdict: Sendable {}
111+
extension SESEvent.Status: Sendable {}
112+
#endif

Sources/AWSLambdaEvents/SNS.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -104,3 +104,10 @@ extension SNSEvent.Message.Attribute: Decodable {
104104
}
105105
}
106106
}
107+
108+
#if swift(>=5.6)
109+
extension SNSEvent: Sendable {}
110+
extension SNSEvent.Record: Sendable {}
111+
extension SNSEvent.Message: Sendable {}
112+
extension SNSEvent.Message.Attribute: Sendable {}
113+
#endif

Sources/AWSLambdaEvents/SQS.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAWSLambdaRuntime open source project
44
//
5-
// Copyright (c) 2017-2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors
5+
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -93,3 +93,9 @@ extension SQSEvent.Message.Attribute: Decodable {
9393
}
9494
}
9595
}
96+
97+
#if swift(>=5.6)
98+
extension SQSEvent: Sendable {}
99+
extension SQSEvent.Message: Sendable {}
100+
extension SQSEvent.Message.Attribute: Sendable {}
101+
#endif

Sources/AWSLambdaEvents/Utils/DateWrappers.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if swift(>=5.6)
16+
@preconcurrency import struct Foundation.Date
17+
#else
1518
import struct Foundation.Date
19+
#endif
1620
import class Foundation.DateFormatter
1721
import struct Foundation.Locale
1822
import struct Foundation.TimeZone
@@ -114,3 +118,9 @@ public struct RFC5322DateTimeCoding: Decodable {
114118
return [formatterWithDay, formatterWithoutDay]
115119
}
116120
}
121+
122+
#if swift(>=5.6)
123+
extension ISO8601Coding: Sendable {}
124+
extension ISO8601WithFractionalSecondsCoding: Sendable {}
125+
extension RFC5322DateTimeCoding: Sendable {}
126+
#endif

Sources/AWSLambdaEvents/Utils/HTTP.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ extension HTTPResponseStatus: Codable {
158158

159159
extension String {
160160
internal var isValidHTTPToken: Bool {
161-
self.utf8.allSatisfy { (char) -> Bool in
161+
self.utf8.allSatisfy { char -> Bool in
162162
switch char {
163163
case UInt8(ascii: "a") ... UInt8(ascii: "z"),
164164
UInt8(ascii: "A") ... UInt8(ascii: "Z"),
@@ -185,3 +185,8 @@ extension String {
185185
}
186186
}
187187
}
188+
189+
#if swift(>=5.6)
190+
extension HTTPMethod: Sendable {}
191+
extension HTTPResponseStatus: Sendable {}
192+
#endif

scripts/soundness.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1919

2020
function replace_acceptable_years() {
2121
# this needs to replace all acceptable forms with 'YEARS'
22-
sed -e 's/2017-2018/YEARS/' -e 's/2017-2020/YEARS/' -e 's/2017-2021/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/'
22+
sed -e 's/2017-2018/YEARS/' -e 's/2017-2020/YEARS/' -e 's/2017-2021/YEARS/' -e 's/2017-2022/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/'
2323
}
2424

2525
printf "=> Checking for unacceptable language... "

0 commit comments

Comments
 (0)