Skip to content

Commit 5f14bb9

Browse files
authored
Address warnings under -strict-concurrency=complete compiler flag. (#18)
Address warnings under -strict-concurrency=complete compiler flag.
1 parent 5e602c4 commit 5f14bb9

23 files changed

+75
-78
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ All or a subset of the rows from a partition can be retrieved using a query-
176176
enum TestPolymorphicOperationReturnType: PolymorphicOperationReturnType {
177177
typealias AttributesType = StandardPrimaryKeyAttributes
178178

179-
static var types: [(Codable.Type, PolymorphicOperationReturnOption<StandardPrimaryKeyAttributes, Self>)] = [
179+
static let types: [(Codable.Type, PolymorphicOperationReturnOption<StandardPrimaryKeyAttributes, Self>)] = [
180180
(TypeA.self, .init( {.typeA($0)} )),
181181
(TypeB.self, .init( {.typeB($0)} )),
182182
]
@@ -728,8 +728,8 @@ public struct MyTimeToLiveAttributes: TimeToLiveAttributes {
728728
If the `Codable` type is used for a row type also conforms to the `CustomRowTypeIdentifier`, the *rowTypeIdentifier* property of this type will be used as the RowType recorded in the database row.
729729

730730
```swift
731-
struct TypeB: Codable, CustomRowTypeIdentifier {
732-
static var rowTypeIdentifier: String? = "TypeBCustom"
731+
struct TypeB: SCodable, CustomRowTypeIdentifier {
732+
static let rowTypeIdentifier: String? = "TypeBCustom"
733733

734734
let thirdly: String
735735
let fourthly: String

Sources/DynamoDBTables/AWSDynamoDBCompositePrimaryKeyTable+monomorphicGetItems.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
4242
monitors the unprocessed items returned in the response from DynamoDB and uses an exponential backoff algorithm to retry those items using
4343
the same retry configuration as the underlying DynamoDB client.
4444
*/
45-
private class MonomorphicGetItemsRetriable<AttributesType: PrimaryKeyAttributes, ItemType: Codable> {
45+
private class MonomorphicGetItemsRetriable<AttributesType: PrimaryKeyAttributes, ItemType: Sendable & Codable> {
4646
typealias OutputType = [CompositePrimaryKey<AttributesType>: TypedDatabaseItem<AttributesType, ItemType>]
4747

4848
let dynamodb: AWSDynamoDB.DynamoDBClient

Sources/DynamoDBTables/CompositePrimaryKey.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import Foundation
2828

29-
public protocol PrimaryKeyAttributes {
29+
public protocol PrimaryKeyAttributes: Sendable {
3030
static var partitionKeyAttributeName: String { get }
3131
static var sortKeyAttributeName: String { get }
3232
static var indexName: String? { get }
@@ -66,7 +66,7 @@ struct DynamoDBAttributesTypeCodingKey: CodingKey {
6666
}
6767
}
6868

69-
public struct CompositePrimaryKey<AttributesType: PrimaryKeyAttributes>: Codable, CustomStringConvertible, Hashable {
69+
public struct CompositePrimaryKey<AttributesType: PrimaryKeyAttributes>: Sendable, Codable, CustomStringConvertible, Hashable {
7070
public var description: String {
7171
"CompositePrimaryKey(partitionKey: \(self.partitionKey), sortKey: \(self.sortKey))"
7272
}

Sources/DynamoDBTables/DynamoDBCompositePrimaryKeyTable+clobberVersionedItemWithHistoricalRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public extension DynamoDBCompositePrimaryKeyTable {
4444
version number.
4545
- completion: completion handler providing an error that was thrown or nil
4646
*/
47-
func clobberVersionedItemWithHistoricalRow<AttributesType: PrimaryKeyAttributes, ItemType: Codable>(
47+
func clobberVersionedItemWithHistoricalRow<AttributesType: PrimaryKeyAttributes, ItemType: Sendable & Codable>(
4848
forPrimaryKey partitionKey: String,
4949
andHistoricalKey historicalKey: String,
5050
item: ItemType,

Sources/DynamoDBTables/DynamoDBCompositePrimaryKeyTable+conditionallyUpdateItem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public extension DynamoDBCompositePrimaryKeyTable {
4343
withRetries: the number of times to attempt to retry the update before failing.
4444
updatedPayloadProvider: the provider that will return updated payloads.
4545
*/
46-
func conditionallyUpdateItem<AttributesType, ItemType: Codable>(
46+
func conditionallyUpdateItem<AttributesType, ItemType: Sendable & Codable>(
4747
forKey key: CompositePrimaryKey<AttributesType>,
4848
withRetries retries: Int = 10,
4949
updatedPayloadProvider: @escaping (ItemType) async throws -> ItemType) async throws
@@ -60,7 +60,7 @@ public extension DynamoDBCompositePrimaryKeyTable {
6060

6161
// Explicitly specify an overload with sync updatedPayloadProvider
6262
// to avoid the compiler matching a call site with such a provider with the EventLoopFuture-returning overload.
63-
func conditionallyUpdateItem<AttributesType, ItemType: Codable>(
63+
func conditionallyUpdateItem<AttributesType, ItemType: Sendable & Codable>(
6464
forKey key: CompositePrimaryKey<AttributesType>,
6565
withRetries retries: Int = 10,
6666
updatedPayloadProvider: @escaping (ItemType) throws -> ItemType) async throws

Sources/DynamoDBTables/DynamoDBCompositePrimaryKeyTable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public extension Swift.Error {
7070
/**
7171
Enumeration of the types of conditions that can be specified for an attribute.
7272
*/
73-
public enum AttributeCondition {
73+
public enum AttributeCondition: Sendable {
7474
case equals(String)
7575
case lessThan(String)
7676
case lessThanOrEqual(String)
@@ -80,7 +80,7 @@ public enum AttributeCondition {
8080
case beginsWith(String)
8181
}
8282

83-
public enum WriteEntry<AttributesType: PrimaryKeyAttributes, ItemType: Codable> {
83+
public enum WriteEntry<AttributesType: PrimaryKeyAttributes, ItemType: Sendable & Codable>: Sendable {
8484
case update(new: TypedDatabaseItem<AttributesType, ItemType>, existing: TypedDatabaseItem<AttributesType, ItemType>)
8585
case insert(new: TypedDatabaseItem<AttributesType, ItemType>)
8686
case deleteAtKey(key: CompositePrimaryKey<AttributesType>)

Sources/DynamoDBTables/InMemoryDynamoDBCompositePrimaryKeyTable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
// DynamoDBTables
2626
//
2727

28-
import AWSDynamoDB
28+
@preconcurrency import AWSDynamoDB
2929
import Foundation
3030

31-
public protocol PolymorphicOperationReturnTypeConvertable {
31+
public protocol PolymorphicOperationReturnTypeConvertable: Sendable {
3232
var createDate: Foundation.Date { get }
3333
var rowStatus: RowStatus { get }
3434

@@ -41,7 +41,7 @@ extension TypedDatabaseItem: PolymorphicOperationReturnTypeConvertable {
4141
}
4242
}
4343

44-
public typealias ExecuteItemFilterType = (String, String, String, PolymorphicOperationReturnTypeConvertable)
44+
public typealias ExecuteItemFilterType = @Sendable (String, String, String, PolymorphicOperationReturnTypeConvertable)
4545
-> Bool
4646

4747
public protocol InMemoryTransactionDelegate {

Sources/DynamoDBTables/InMemoryDynamoDBCompositePrimaryKeysProjection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ import Foundation
3131
public struct InMemoryDynamoDBCompositePrimaryKeysProjection: DynamoDBCompositePrimaryKeysProjection {
3232
let keysWrapper: InMemoryDynamoDBCompositePrimaryKeysProjectionStore
3333

34-
public init(keys: [Any] = []) {
34+
public init(keys: [Sendable] = []) {
3535
self.keysWrapper = InMemoryDynamoDBCompositePrimaryKeysProjectionStore(keys: keys)
3636
}
3737

3838
init(keysWrapper: InMemoryDynamoDBCompositePrimaryKeysProjectionStore) {
3939
self.keysWrapper = keysWrapper
4040
}
4141

42-
public var keys: [Any] {
42+
public var keys: [Sendable] {
4343
get async {
4444
await self.keysWrapper.keys
4545
}

Sources/DynamoDBTables/InMemoryDynamoDBCompositePrimaryKeysProjectionStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import Foundation
3131
// MARK: - Store implementation
3232

3333
actor InMemoryDynamoDBCompositePrimaryKeysProjectionStore {
34-
public var keys: [Any] = []
34+
public var keys: [Sendable] = []
3535

36-
public init(keys: [Any] = []) {
36+
public init(keys: [Sendable] = []) {
3737
self.keys = keys
3838
}
3939

Sources/DynamoDBTables/PolymorphicOperationReturnType.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,27 @@ public protocol BatchCapableReturnType {
3333
func getItemKey() -> CompositePrimaryKey<AttributesType>
3434
}
3535

36-
public protocol PolymorphicOperationReturnType {
36+
public protocol PolymorphicOperationReturnType: Sendable {
3737
associatedtype AttributesType: PrimaryKeyAttributes
3838

3939
static var types: [(Codable.Type, PolymorphicOperationReturnOption<AttributesType, Self>)] { get }
4040
}
4141

42-
public struct PolymorphicOperationReturnOption<AttributesType: PrimaryKeyAttributes, ReturnType> {
43-
private let decodingPayloadHandler: (Decoder) throws -> ReturnType
44-
private let typeConvertingPayloadHander: (Any) throws -> ReturnType
42+
public struct PolymorphicOperationReturnOption<AttributesType: PrimaryKeyAttributes, ReturnType>: Sendable {
43+
private let decodingPayloadHandler: @Sendable (Decoder) throws -> ReturnType
44+
private let typeConvertingPayloadHander: @Sendable (Any) throws -> ReturnType
4545

4646
public init<RowType: Codable>(
47-
_ payloadHandler: @escaping (TypedDatabaseItem<AttributesType, RowType>) -> ReturnType)
47+
_ payloadHandler: @escaping @Sendable (TypedDatabaseItem<AttributesType, RowType>) -> ReturnType)
4848
{
49+
@Sendable
4950
func newDecodingPayloadHandler(decoder: Decoder) throws -> ReturnType {
5051
let typedDatabaseItem: TypedDatabaseItem<AttributesType, RowType> = try TypedDatabaseItem(from: decoder)
5152

5253
return payloadHandler(typedDatabaseItem)
5354
}
5455

56+
@Sendable
5557
func newTypeConvertingPayloadHandler(input: Any) throws -> ReturnType {
5658
guard let typedDatabaseItem = input as? TypedDatabaseItem<AttributesType, RowType> else {
5759
let description = "Expected to use item type \(TypedDatabaseItem<AttributesType, RowType>.self)."

Sources/DynamoDBTables/PolymorphicWriteEntry.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public protocol PolymorphicTransactionConstraintTransform {
4444

4545
// Conforming types are provided by the application to express the different possible write entries
4646
// and how they can be converted to the table-provided transform type.
47-
public protocol PolymorphicWriteEntry {
47+
public protocol PolymorphicWriteEntry: Sendable {
4848
func handle<Context: PolymorphicWriteEntryContext>(context: Context) throws -> Context.WriteEntryTransformType
4949

5050
var compositePrimaryKey: StandardCompositePrimaryKey? { get }
@@ -58,13 +58,13 @@ public extension PolymorphicWriteEntry {
5858

5959
public typealias StandardTransactionConstraintEntry<ItemType: Codable> = TransactionConstraintEntry<StandardPrimaryKeyAttributes, ItemType>
6060

61-
public enum TransactionConstraintEntry<AttributesType: PrimaryKeyAttributes, ItemType: Codable> {
61+
public enum TransactionConstraintEntry<AttributesType: PrimaryKeyAttributes, ItemType: Sendable & Codable>: Sendable {
6262
case required(existing: TypedDatabaseItem<AttributesType, ItemType>)
6363
}
6464

6565
// Conforming types are provided by the application to express the different possible constraint entries
6666
// and how they can be converted to the table-provided transform type.
67-
public protocol PolymorphicTransactionConstraintEntry {
67+
public protocol PolymorphicTransactionConstraintEntry: Sendable {
6868
func handle<Context: PolymorphicWriteEntryContext>(context: Context) throws -> Context.WriteTransactionConstraintType
6969

7070
var compositePrimaryKey: StandardCompositePrimaryKey? { get }

Sources/DynamoDBTables/RetryConfiguration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public typealias RetryInterval = UInt32
3232
/**
3333
Retry configuration for the requests made by a table..
3434
*/
35-
public struct RetryConfiguration {
35+
public struct RetryConfiguration: Sendable {
3636
// Number of retries to be attempted
3737
public let numRetries: Int
3838
// First interval of retry in millis
@@ -80,10 +80,10 @@ public struct RetryConfiguration {
8080
}
8181

8282
/// Default try configuration with 5 retries starting at 500 ms interval.
83-
public static var `default` = RetryConfiguration(numRetries: 5, baseRetryInterval: 500,
83+
public static let `default` = RetryConfiguration(numRetries: 5, baseRetryInterval: 500,
8484
maxRetryInterval: 10000, exponentialBackoff: 2)
8585

8686
/// Retry Configuration with no retries.
87-
public static var noRetries = RetryConfiguration(numRetries: 0, baseRetryInterval: 0,
87+
public static let noRetries = RetryConfiguration(numRetries: 0, baseRetryInterval: 0,
8888
maxRetryInterval: 0, exponentialBackoff: 0)
8989
}

Sources/DynamoDBTables/RowWithIndex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public func createRowWithIndexCodingKey(stringValue: String) -> RowWithIndexCodi
5151
RowWithIndexCodingKey(stringValue: stringValue)!
5252
}
5353

54-
public struct RowWithIndex<RowType: Codable, Identity: IndexIdentity>: Codable, CustomRowTypeIdentifier {
54+
public struct RowWithIndex<RowType: Sendable & Codable, Identity: IndexIdentity>: Sendable, Codable, CustomRowTypeIdentifier {
5555
public static var rowTypeIdentifier: String? {
5656
let rowTypeIdentity = getTypeRowIdentifier(type: RowType.self)
5757
let indexIdentity = Identity.identity

Sources/DynamoDBTables/RowWithItemVersion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import Foundation
2828

29-
public struct RowWithItemVersion<RowType: Codable>: Codable, CustomRowTypeIdentifier {
29+
public struct RowWithItemVersion<RowType: Sendable & Codable>: Sendable, Codable, CustomRowTypeIdentifier {
3030
public static var rowTypeIdentifier: String? {
3131
let rowTypeIdentity = getTypeRowIdentifier(type: RowType.self)
3232

Sources/DynamoDBTables/TimeToLive.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct StandardTimeToLiveAttributes: TimeToLiveAttributes {
3838

3939
public typealias StandardTimeToLive = TimeToLive<StandardTimeToLiveAttributes>
4040

41-
public struct TimeToLive<AttributesType: TimeToLiveAttributes>: Codable, CustomStringConvertible, Hashable {
41+
public struct TimeToLive<AttributesType: TimeToLiveAttributes>: Sendable, Codable, CustomStringConvertible, Hashable {
4242
public var description: String {
4343
"TimeToLive(timeToLiveTimestamp: \(self.timeToLiveTimestamp)"
4444
}

Sources/DynamoDBTables/TypedDatabaseItemWithTimeToLive.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import Foundation
2828

29-
public struct RowStatus: Codable {
29+
public struct RowStatus: Sendable, Codable {
3030
public let rowVersion: Int
3131
public let lastUpdatedDate: Date
3232

@@ -41,7 +41,7 @@ public struct RowStatus: Codable {
4141
}
4242
}
4343

44-
public protocol DatabaseItem {
44+
public protocol DatabaseItem: Sendable {
4545
associatedtype AttributesType: PrimaryKeyAttributes
4646
// Default to StandardTimeToLiveAttributes for backwards compatibility
4747
associatedtype TimeToLiveAttributesType: TimeToLiveAttributes = StandardTimeToLiveAttributes
@@ -61,11 +61,11 @@ public extension DatabaseItem {
6161
public protocol StandardDatabaseItem: DatabaseItem where AttributesType == StandardPrimaryKeyAttributes {}
6262

6363
// Default to StandardTimeToLiveAttributes for backwards compatibility
64-
public typealias TypedDatabaseItem<AttributesType: PrimaryKeyAttributes, RowType: Codable> = TypedDatabaseItemWithTimeToLive<AttributesType, RowType, StandardTimeToLiveAttributes>
64+
public typealias TypedDatabaseItem<AttributesType: PrimaryKeyAttributes, RowType: Sendable & Codable> = TypedDatabaseItemWithTimeToLive<AttributesType, RowType, StandardTimeToLiveAttributes>
6565

6666
public struct TypedDatabaseItemWithTimeToLive<AttributesType: PrimaryKeyAttributes,
67-
RowType: Codable,
68-
TimeToLiveAttributesType: TimeToLiveAttributes>: DatabaseItem, Codable
67+
RowType: Sendable & Codable,
68+
TimeToLiveAttributesType: TimeToLiveAttributes>: DatabaseItem, Sendable, Codable
6969
{
7070
public let compositePrimaryKey: CompositePrimaryKey<AttributesType>
7171
public let createDate: Date

Tests/DynamoDBTablesTests/DynamoDBCompositePrimaryKeyTableHistoricalItemExtensionsTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ private typealias DatabaseRowType =
3636
* For these tests, a primary item Provider should always return a default value for nil arguments. The Provider Provider requires a non-nil default in order to initialize a Provider.
3737
*/
3838
private func primaryItemProviderProvider(_ defaultItem: DatabaseRowType) ->
39-
(DatabaseRowType?) -> DatabaseRowType
39+
@Sendable (DatabaseRowType?) -> DatabaseRowType
4040
{
41+
@Sendable
4142
func primaryItemProvider(_ item: DatabaseRowType?) ->
4243
DatabaseRowType
4344
{

Tests/DynamoDBTablesTests/DynamoDBEncoderDecoderTests.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
@testable import DynamoDBTables
2828
import XCTest
2929

30-
private let dynamodbEncoder = DynamoDBEncoder()
31-
private let dynamodbDecoder = DynamoDBDecoder()
32-
3330
struct CoreAccountAttributes: Codable {
3431
var description: String
3532
var mappedValues: [String: String]
@@ -64,14 +61,14 @@ class DynamoDBEncoderDecoderTests: XCTestCase {
6461
mappedValues: ["A": "one", "B": "two"],
6562
notificationTargets: NotificationTargets(currentIDs: [], maximum: 20))
6663

67-
func testEncoderDecoder() {
64+
func testEncoderDecoder() throws {
6865
// create key and database item to create
6966
let key = StandardCompositePrimaryKey(partitionKey: partitionKey, sortKey: sortKey)
7067
let newDatabaseItem: DatabaseItemType = StandardTypedDatabaseItem.newItem(withKey: key, andValue: self.attributes)
7168

72-
let encodedAttributeValue = try! dynamodbEncoder.encode(newDatabaseItem)
69+
let encodedAttributeValue = try DynamoDBEncoder().encode(newDatabaseItem)
7370

74-
let output: DatabaseItemType = try! dynamodbDecoder.decode(encodedAttributeValue)
71+
let output: DatabaseItemType = try DynamoDBDecoder().decode(encodedAttributeValue)
7572

7673
XCTAssertEqual(newDatabaseItem.rowValue, output.rowValue)
7774
XCTAssertEqual(self.partitionKey, output.compositePrimaryKey.partitionKey)
@@ -80,7 +77,7 @@ class DynamoDBEncoderDecoderTests: XCTestCase {
8077
XCTAssertNil(output.timeToLive)
8178
}
8279

83-
func testEncoderDecoderWithTimeToLive() {
80+
func testEncoderDecoderWithTimeToLive() throws {
8481
let timeToLiveTimestamp: Int64 = 123_456_789
8582
let timeToLive = StandardTimeToLive(timeToLiveTimestamp: timeToLiveTimestamp)
8683

@@ -91,9 +88,9 @@ class DynamoDBEncoderDecoderTests: XCTestCase {
9188
andValue: self.attributes,
9289
andTimeToLive: timeToLive)
9390

94-
let encodedAttributeValue = try! dynamodbEncoder.encode(newDatabaseItem)
91+
let encodedAttributeValue = try DynamoDBEncoder().encode(newDatabaseItem)
9592

96-
let output: DatabaseItemType = try! dynamodbDecoder.decode(encodedAttributeValue)
93+
let output: DatabaseItemType = try DynamoDBDecoder().decode(encodedAttributeValue)
9794

9895
XCTAssertEqual(newDatabaseItem.rowValue, output.rowValue)
9996
XCTAssertEqual(self.partitionKey, output.compositePrimaryKey.partitionKey)

Tests/DynamoDBTablesTests/InMemoryDynamoDBCompositePrimaryKeyTableTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import XCTest
3131
enum TestPolymorphicOperationReturnType: PolymorphicOperationReturnType {
3232
typealias AttributesType = StandardPrimaryKeyAttributes
3333

34-
static var types: [(Codable.Type, PolymorphicOperationReturnOption<StandardPrimaryKeyAttributes, Self>)] = [
34+
static let types: [(Codable.Type, PolymorphicOperationReturnOption<StandardPrimaryKeyAttributes, Self>)] = [
3535
(TestTypeA.self, .init { .testTypeA($0) }),
3636
]
3737

0 commit comments

Comments
 (0)