Skip to content

Commit bf63287

Browse files
authored
feat(hulk): update tags in chunks of 25 (#23)
1 parent e6fe9ee commit bf63287

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Sources/App/Array+chunked.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
extension Array {
4+
func chunked(into size: Int) -> [[Element]] {
5+
stride(from: 0, to: count, by: size).map {
6+
Array(self[$0..<Swift.min($0 + size, count)])
7+
}
8+
}
9+
}

Sources/App/Hulk.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public struct Hulk {
6363

6464
logger.info("will smash tags \(tags)")
6565

66-
try await asgClient.updateTags(tags)
66+
for chunk in tags.chunked(into: 25) {
67+
logger.info("smashing chunk of tags \(chunk)")
68+
69+
try await asgClient.updateTags(chunk)
70+
}
6771

6872
logger.info("smashed tags with \(clusterInfo)")
6973
}

0 commit comments

Comments
 (0)