class Bifrost::Bus
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
Attributes
interface[R]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
create_topic(name)
click to toggle source
To encapsulate the underlying bus object we provide a custom interface for the methods of the Azure smb we use
# File lib/bifrost/bus.rb, line 19 def create_topic(name) @interface.create_topic(name) end
delete_topic(name)
click to toggle source
# File lib/bifrost/bus.rb, line 23 def delete_topic(name) @interface.delete_topic(name) end
topic_exists?(topic)
click to toggle source
Tells us if the topic has already been defined
# File lib/bifrost/bus.rb, line 35 def topic_exists?(topic) topics.include?(topic) end
topics()
click to toggle source
This method returns a list of topics currently defined on the Bifrost
# File lib/bifrost/bus.rb, line 28 def topics @interface.list_topics.map do |t| Topic.new(t.name) end end
Private Instance Methods
key()
click to toggle source
Simple utlity method to keep the code legible
# File lib/bifrost/bus.rb, line 42 def key ENV['AZURE_BUS_KEY_NAME'] end
secret()
click to toggle source
# File lib/bifrost/bus.rb, line 46 def secret ENV['AZURE_BUS_KEY_SECRET'] end