Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit a9f9c46

Browse files
committed
Concurrent uploading in mirror services
1 parent 8043398 commit a9f9c46

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/active_storage/service/mirror_service.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ def initialize(primary:, mirrors:)
1818
end
1919

2020
def upload(key, io, checksum: nil)
21-
each_service.collect do |service|
22-
service.upload key, io.tap(&:rewind), checksum: checksum
23-
end
21+
perform_across_services :upload, key, io.tap(&:rewind), checksum: checksum
2422
end
2523

2624
def delete(key)
@@ -33,9 +31,9 @@ def each_service(&block)
3331
end
3432

3533
def perform_across_services(method, *args)
36-
promises = services.collect do |service|
34+
promises = each_service.collect do |service|
3735
Concurrent::Promise.execute { service.public_send method, *args }
3836
end
39-
Concurrent::Promise.zip(*promises).value
37+
Concurrent::Promise.zip(*promises).value!
4038
end
4139
end

0 commit comments

Comments
 (0)