class ActiveStorage::Service::MirrorService

and url.
have the files uploaded to them. A primary service is designated to answer calls to download, exists?,
Wraps a set of mirror services and provides a single ActiveStorage::Service object that will all

def self.build(primary:, mirrors:, configurator:, **options) #:nodoc:

:nodoc:
Stitch together from named services.
def self.build(primary:, mirrors:, configurator:, **options) #:nodoc:
  new \
    primary: configurator.build(primary),
    mirrors: mirrors.collect { |name| configurator.build name }
end

def delete(key)

Delete the file at the +key+ on all services.
def delete(key)
  perform_across_services :delete, key
end

def each_service(&block)

def each_service(&block)
  [ primary, *mirrors ].each(&block)
end

def initialize(primary:, mirrors:)

def initialize(primary:, mirrors:)
  @primary, @mirrors = primary, mirrors
end

def perform_across_services(method, *args)

def perform_across_services(method, *args)
  # FIXME: Convert to be threaded
  each_service.collect do |service|
    service.public_send method, *args
  end
end

def upload(key, io, checksum: nil)

ensure a match when the upload has completed or raise an ActiveStorage::IntegrityError.
Upload the +io+ to the +key+ specified to all services. If a +checksum+ is provided, all services will
def upload(key, io, checksum: nil)
  each_service.collect do |service|
    service.upload key, io.tap(&:rewind), checksum: checksum
  end
end