Skip to content

Commit e79dea1

Browse files
committed
Restore from glacier in parallel
Signed-off-by: Samuel Giddins <[email protected]>
1 parent 929a013 commit e79dea1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bin/initiate-backfill

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gemfile do
1010
gem "logger"
1111
gem "base64"
1212
gem "activesupport", require: "active_support/all"
13+
gem "parallel"
1314
end
1415

1516
continuation_token_file = File.join(__dir__, ".initiate-backfill.continuation_token")
@@ -26,14 +27,16 @@ stats = Hash.new do |h, k|
2627
y, m = k
2728
h[k] = Stats.new(y, m, 0, 0)
2829
end
29-
30+
MUTEX = Mutex.new
3031
increment = lambda do |object|
3132
k = object.key.match(/fastly_json\/(\d{4}).(\d{2})/)&.captures || (
3233
puts "\nIgnoring #{object.key.inspect}";
3334
return
3435
)
35-
puts stats.values.last unless stats.key?(k)
36-
stats[k].increment(object)
36+
MUTEX.synchronize do
37+
puts stats.values.last unless stats.key?(k)
38+
stats[k].increment(object)
39+
end
3740
end
3841

3942
client = Aws::S3::Client.new
@@ -45,7 +48,7 @@ begin
4548
continuation_token:,
4649
)
4750

48-
response.contents.each do |object|
51+
Parallel.each(response.contents, in_threads: 10) do |object|
4952
increment.call(object)
5053
client.restore_object(
5154
bucket:,

0 commit comments

Comments
 (0)