From e8232e8491c85e183dd6eee8fc431a4fd12bd165 Mon Sep 17 00:00:00 2001 From: Austin Payne Date: Sat, 15 Feb 2025 17:00:56 -0700 Subject: [PATCH 1/2] refactor: use standardized swift-async-algorithms Adopts the more common (now-a-days) swift-async-algorithms for the simple async collection needs of this package. Helps adopt the standardized ecosystem where many other packages use swift-async-algorithms. --- Package.resolved | 16 ++++++++-------- Package.swift | 4 ++-- Sources/AsyncDataLoader/DataLoader.swift | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Package.resolved b/Package.resolved index 7b8fae1..0c0a579 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,21 +1,21 @@ { "pins" : [ { - "identity" : "async-collections", + "identity" : "swift-algorithms", "kind" : "remoteSourceControl", - "location" : "https://github.com/adam-fowler/async-collections", + "location" : "https://github.com/apple/swift-algorithms.git", "state" : { - "revision" : "726af96095a19df6b8053ddbaed0a727aa70ccb2", - "version" : "0.1.0" + "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", + "version" : "1.2.0" } }, { - "identity" : "swift-algorithms", + "identity" : "swift-async-algorithms", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-algorithms.git", + "location" : "https://github.com/apple/swift-async-algorithms.git", "state" : { - "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", - "version" : "1.2.0" + "revision" : "4c3ea81f81f0a25d0470188459c6d4bf20cf2f97", + "version" : "1.0.3" } }, { diff --git a/Package.swift b/Package.swift index f67250b..ec8b12f 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"), - .package(url: "https://github.com/adam-fowler/async-collections", from: "0.0.1"), + .package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"), .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"), ], targets: [ @@ -27,7 +27,7 @@ let package = Package( name: "AsyncDataLoader", dependencies: [ .product(name: "Algorithms", package: "swift-algorithms"), - .product(name: "AsyncCollections", package: "async-collections"), + .product(name: "AsyncAlgorithms", package: "swift-async-algorithms"), ] ), .testTarget(name: "DataLoaderTests", dependencies: ["DataLoader"]), diff --git a/Sources/AsyncDataLoader/DataLoader.swift b/Sources/AsyncDataLoader/DataLoader.swift index d60b829..c8a5d6e 100644 --- a/Sources/AsyncDataLoader/DataLoader.swift +++ b/Sources/AsyncDataLoader/DataLoader.swift @@ -1,5 +1,5 @@ import Algorithms -import AsyncCollections +import AsyncAlgorithms public enum DataLoaderValue: Sendable { case success(T) @@ -117,7 +117,7 @@ public actor DataLoader { return [] } - return try await keys.concurrentMap { try await self.load(key: $0) } + return try await Array(keys.async.map { try await self.load(key: $0) }) } /// Clears the value at `key` from the cache, if it exists. Returns itself for @@ -177,8 +177,8 @@ public actor DataLoader { // If a maxBatchSize was provided and the queue is longer, then segment the // queue into multiple batches, otherwise treat the queue as a single batch. if let maxBatchSize = options.maxBatchSize, maxBatchSize > 0, maxBatchSize < batch.count { - try await batch.chunks(ofCount: maxBatchSize).asyncForEach { slicedBatch in - try await self.executeBatch(batch: Array(slicedBatch)) + for try await slicedBatch in batch.chunks(ofCount: maxBatchSize).async { + try await executeBatch(batch: Array(slicedBatch)) } } else { try await executeBatch(batch: batch) From 3b7d9795798a33a4ebf62a49674ee28fe9daca88 Mon Sep 17 00:00:00 2001 From: Austin Payne Date: Sun, 16 Feb 2025 15:43:14 -0700 Subject: [PATCH 2/2] ci: update to upload-artifact v4 v3 has been deprecated, see: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5887173..2294be4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: --format html \ --output-dir=.test-coverage - name: Upload test coverage html - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-coverage-report path: .test-coverage @@ -68,4 +68,4 @@ jobs: swift-version: ${{ matrix.swift }} - uses: actions/checkout@v3 - name: Test - run: swift test --parallel \ No newline at end of file + run: swift test --parallel