Module: Debci::AMQP
- Defined in:
- lib/debci/amqp.rb
Constant Summary collapse
- QUEUE_ALIASES =
Some queues are used for multiple backends
{ 'incus-lxc' => 'lxc', 'lxd-lxc' => 'lxc', }.freeze
Class Method Summary collapse
- .amqp_channel ⇒ Object
- .amqp_options ⇒ Object
- .conn ⇒ Object
- .get_queue(arch, backend = Debci.config.backend) ⇒ Object
- .queue_exists?(arch, backend) ⇒ Boolean
- .queue_name(arch, backend) ⇒ Object
- .results_queue ⇒ Object
Class Method Details
.amqp_channel ⇒ Object
44 45 46 |
# File 'lib/debci/amqp.rb', line 44 def self.amqp_channel @channel ||= conn.create_channel end |
.amqp_options ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/debci/amqp.rb', line 48 def self. { 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 |
.conn ⇒ Object
38 39 40 41 42 |
# File 'lib/debci/amqp.rb', line 38 def self.conn @conn ||= Bunny.new(Debci.config.amqp_server, ).tap do |c| c.start end end |
.get_queue(arch, backend = Debci.config.backend) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/debci/amqp.rb', line 13 def self.get_queue(arch, backend = Debci.config.backend) opts = { durable: true, arguments: { 'x-max-priority': 10, } } q = queue_name(arch, backend) self.amqp_channel.queue(q, opts) end |
.queue_exists?(arch, backend) ⇒ Boolean
24 25 26 |
# File 'lib/debci/amqp.rb', line 24 def self.queue_exists?(arch, backend) conn.queue_exists?(queue_name(arch, backend)) end |
.queue_name(arch, backend) ⇒ Object
28 29 30 31 |
# File 'lib/debci/amqp.rb', line 28 def self.queue_name(arch, backend) queue_type = QUEUE_ALIASES[backend] || backend "debci-tests-#{arch}-#{queue_type}" end |