File: broker.rb

package info (click to toggle)
ruby-amqp 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,508 kB
  • sloc: ruby: 8,272; sh: 11; makefile: 10
file content (72 lines) | stat: -rw-r--r-- 1,655 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# encoding: utf-8

module AMQP
  # A utility class that makes inspection of broker capabilities easier.
  class Broker

    #
    # API
    #

    RABBITMQ_PRODUCT = "RabbitMQ".freeze

    # Broker information
    # @return [Hash]
    # @see Session#server_properties
    attr_reader :properties

    # @return [Hash] properties Broker information
    # @see Session#server_properties
    def initialize(properties)
      @properties = properties
    end # initialize(properties)

    # @group Product information

    # @return [Boolean] true if broker is RabbitMQ
    def rabbitmq?
      self.product == RABBITMQ_PRODUCT
    end # rabbitmq?

    # @return [String] Broker product information
    def product
      @product ||= @properties["product"]
    end # product

    # @return [String] Broker version
    def version
      @version ||= @properties["version"]
    end # version

    # @endgroup



    # @group Product capabilities

    # @return [Boolean]
    def supports_publisher_confirmations?
      @properties["capabilities"]["publisher_confirms"]
    end # supports_publisher_confirmations?

    # @return [Boolean]
    def supports_basic_nack?
      @properties["capabilities"]["basic.nack"]
    end # supports_basic_nack?

    # @return [Boolean]
    def supports_consumer_cancel_notifications?
      @properties["capabilities"]["consumer_cancel_notify"]
    end # supports_consumer_cancel_notifications?

    # @return [Boolean]
    def supports_exchange_to_exchange_bindings?
      @properties["capabilities"]["exchange_exchange_bindings"]
    end # supports_exchange_to_exchange_bindings?


    # @endgroup


  end # Broker
end # AMQP