Class: Bifrost::Bus
- Inherits:
-
Object
- Object
- Bifrost::Bus
- Defined in:
- lib/bifrost/bus.rb
Overview
This type represents the Bifrost as a managed entity NOTE: Warning, this object should never use shared state as it is referenced initialize each worker
Instance Attribute Summary collapse
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
Instance Method Summary collapse
-
#create_topic(name) ⇒ Object
To encapsulate the underlying bus object we provide a custom interface for the methods of the Azure smb we use.
- #delete_topic(name) ⇒ Object
-
#initialize ⇒ Bus
constructor
A new instance of Bus.
-
#topic_exists?(topic) ⇒ Boolean
Tells us if the topic has already been defined.
-
#topics ⇒ Object
This method returns a list of topics currently defined on the Bifrost.
Constructor Details
#initialize ⇒ Bus
Returns a new instance of Bus.
10 11 12 13 14 15 |
# File 'lib/bifrost/bus.rb', line 10 def initialize Azure.sb_namespace = ENV['AZURE_BUS_NAMESPACE'] host = "https://#{Azure.sb_namespace}.servicebus.windows.net" signer = Azure::ServiceBus::Auth::SharedAccessSigner.new(key, secret) @interface ||= Azure::ServiceBus::ServiceBusService.new(host, signer: signer) end |
Instance Attribute Details
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
8 9 10 |
# File 'lib/bifrost/bus.rb', line 8 def interface @interface end |
Instance Method Details
#create_topic(name) ⇒ Object
To encapsulate the underlying bus object we provide a custom interface for the methods of the Azure smb we use
19 20 21 |
# File 'lib/bifrost/bus.rb', line 19 def create_topic(name) @interface.create_topic(name) end |
#delete_topic(name) ⇒ Object
23 24 25 |
# File 'lib/bifrost/bus.rb', line 23 def delete_topic(name) @interface.delete_topic(name) end |
#topic_exists?(topic) ⇒ Boolean
Tells us if the topic has already been defined
35 36 37 |
# File 'lib/bifrost/bus.rb', line 35 def topic_exists?(topic) topics.include?(topic) end |