Class: Uricp::UriStrategy

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging
Defined in:
lib/uricp/uri_strategy.rb

Constant Summary collapse

STRATEGIES =

This is an ordered list from the most specific to the most general

[
  Strategy::RbdCachedGet,
  Strategy::RbdCacheClone,
  Strategy::RbdCacheCheck,
  Strategy::RbdSnap,
  Strategy::CachedGet,
  Strategy::PipedRemoteGet,
  Strategy::PipedRbdGet,
  Strategy::PipedCacheConvert,
  Strategy::PipedCache,
  Strategy::PipedLocalDecompress,
  Strategy::PipedDecompress,
  Strategy::LocalConvert,
  Strategy::LocalLink,
  Strategy::PipedCompress,
  Strategy::RbdCacheUpload,
  Strategy::RbdCachedPut,
  Strategy::RbdPut,
  Strategy::RbdCacheBaseSnap,
  Strategy::SegmentedRemotePut,
  Strategy::RemotePut,
  Strategy::PipedLocalCompress,
  Strategy::PipedLocalGet,
  Strategy::PipedLocalPut,
  Strategy::Cleaner,
  Strategy::RbdSweeper,
  Strategy::Sweeper
].freeze

Class Method Summary collapse

Class Method Details

.choose_strategy(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/uricp/uri_strategy.rb', line 9

def self.choose_strategy(options)
  current = options.reject { |k, _v| k.is_a? Symbol }
  strategy_list = []
  while STRATEGIES.detect { |klass| @strategy = klass.new(current).appropriate? }
    debug "#{name}: Selected strategy #{@strategy.class.name}"
    strategy_list << @strategy
    current = @strategy.proposed_options
  end
  if incomplete_strategy?(strategy_list)
    raise Uricp::UnsupportedURLtype, "Unsupported transfer from #{options['from_uri']} to #{options['to_uri']}"
  end

  strategy_list
end

.incomplete_strategy?(list) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/uricp/uri_strategy.rb', line 24

def self.incomplete_strategy?(list)
  list.empty?
end