Module: Debci::AMQP

Defined in:
lib/debci/amqp.rb

Class Method Summary collapse

Class Method Details

.amqp_channelObject



27
28
29
30
31
32
# File 'lib/debci/amqp.rb', line 27

def self.amqp_channel
  @conn ||= Bunny.new(Debci.config.amqp_server, amqp_options).tap do |conn|
    conn.start
  end
  @channel ||= @conn.create_channel
end

.amqp_optionsObject



34
35
36
37
38
39
40
41
42
# File 'lib/debci/amqp.rb', line 34

def self.amqp_options
  {
    tls:                  Debci.config.amqp_ssl,
    tls_cert:             Debci.config.amqp_cert,
    tls_ca_certificates:  Debci.config.amqp_cacert,
    tls_key:              Debci.config.amqp_key,
    verify_peer:          true,
  }
end

.get_queue(arch, backend = Debci.config.backend) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/debci/amqp.rb', line 7

def self.get_queue(arch, backend = Debci.config.backend)
  @queues ||= {}
  @queues[arch] ||=
    begin
      opts = {
        durable: true,
        arguments: {
          'x-max-priority': 10,
        }
      }
      q = ENV['debci_amqp_queue'] || "debci-tests-#{arch}-#{backend}"
      self.amqp_channel.queue(q, opts)
    end
end

.results_queueObject



22
23
24
25
# File 'lib/debci/amqp.rb', line 22

def self.results_queue
  q = Debci.config.amqp_results_queue
  self.amqp_channel.queue(q, durable: true)
end