Module: Debci::AMQP

Defined in:
lib/debci/amqp.rb

Class Method Summary collapse

Class Method Details

.amqp_channelObject



37
38
39
# File 'lib/debci/amqp.rb', line 37

def self.amqp_channel
  @channel ||= conn.create_channel
end

.amqp_optionsObject



41
42
43
44
45
46
47
48
49
# File 'lib/debci/amqp.rb', line 41

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

.connObject



31
32
33
34
35
# File 'lib/debci/amqp.rb', line 31

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

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



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

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

.queue_exists?(arch, backend) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/debci/amqp.rb', line 18

def self.queue_exists?(arch, backend)
  conn.queue_exists?(queue_name(arch, backend))
end

.queue_name(arch, backend) ⇒ Object



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

def self.queue_name(arch, backend)
  "debci-tests-#{arch}-#{backend}"
end

.results_queueObject



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

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