storage managers: add mirror storage manager.
Add a storage manager that allows mirroring files to multiple storage backends.
This commit is contained in:
29
app/logical/storage_manager/mirror.rb
Normal file
29
app/logical/storage_manager/mirror.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# A StorageManager that mirrors files across multiple storage backends.
|
||||
class StorageManager::Mirror < StorageManager
|
||||
attr_reader :services
|
||||
|
||||
def initialize(services, **options)
|
||||
@services = services
|
||||
super(**options)
|
||||
end
|
||||
|
||||
def store(io, dest_path)
|
||||
services.each do |service|
|
||||
service.store(io, dest_path)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(path)
|
||||
services.each do |service|
|
||||
service.delete(path)
|
||||
end
|
||||
end
|
||||
|
||||
def open(path)
|
||||
services.first.open(path)
|
||||
end
|
||||
|
||||
def file_url(path)
|
||||
services.first.file_url(path)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user