Class: Debci::Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/debci/backend.rb

Class Method Summary collapse

Class Method Details

.backend_listObject



27
28
29
# File 'lib/debci/backend.rb', line 27

def self.backend_list
  Debci.config.backend_list
end

.defaultObject



31
32
33
# File 'lib/debci/backend.rb', line 31

def self.default
  Debci.config.backend
end

.select(backend, arch) ⇒ Object

Select which backend to use, given a preferred backend and the target architecture. The backend specified in the backend attribute will be used if that backend is available for the given architecture; otherwise, the configured backend list is searched, and if no available backend if found, the default backend is used as a fallback. The default backend is assumed to be available.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/debci/backend.rb', line 12

def self.select(backend, arch)
  return default unless backend

  candidates = backend_list.dup
  if backend && candidates.first != backend
    candidates.unshift(backend)
  end

  selected = candidates.find do |candidate|
    Debci::AMQP.queue_exists?(arch, candidate)
  end

  selected || default
end