Class: Qup::Adapter::Kestrel::Topic
- Inherits:
-
Destination
- Object
- Destination
- Qup::Adapter::Kestrel::Topic
- Includes:
- TopicAPI
- Defined in:
- lib/qup/adapter/kestrel/topic.rb
Overview
Internal: The Topic implementation for the Kestrel Adapter
The topic delivers each Message that it is give to each and every Subscriber
Instance Attribute Summary
Attributes inherited from Destination
Instance Method Summary collapse
-
#publish(message) ⇒ Object
Internal: Publish a Message to all the Subscribers.
-
#publisher ⇒ Object
Internal : Creates a Publisher for the Topic.
-
#subscriber(name) ⇒ Object
Internal: Create a subscriber for the Topic.
-
#subscriber_count ⇒ Object
Internal: Return the number of Subscribers to this Topic.
Methods included from TopicAPI
Methods inherited from Destination
Constructor Details
This class inherits a constructor from Qup::Adapter::Kestrel::Destination
Instance Method Details
#publish(message) ⇒ Object
Internal: Publish a Message to all the Subscribers
message - the Object to send to all subscribers
Returns nothing
51 52 53 |
# File 'lib/qup/adapter/kestrel/topic.rb', line 51 def publish( ) @client.set( @name, ) end |
#publisher ⇒ Object
Internal : Creates a Publisher for the Topic
Returns a new Publisher
14 15 16 |
# File 'lib/qup/adapter/kestrel/topic.rb', line 14 def publisher ::Qup::Publisher.new( self ) end |
#subscriber(name) ⇒ Object
Internal: Create a subscriber for the Topic
name - the String name of the subscriber
Creating a subscriber creates a new Subscriber that will receive a copy of every message that is published to the Topic.
Subscribers are unique by name, two subscribers with the same name will act as individual Consumers on a queue of their name.
Returns a Subscriber
29 30 31 |
# File 'lib/qup/adapter/kestrel/topic.rb', line 29 def subscriber( name ) ::Qup::Subscriber.new( self, subscriber_queue( name ) ) end |
#subscriber_count ⇒ Object
Internal: Return the number of Subscribers to this Topic
Returns integer
37 38 39 40 41 42 43 44 |
# File 'lib/qup/adapter/kestrel/topic.rb', line 37 def subscriber_count c = 0 @client.stats['queues'].keys.each do |k| next if k =~ /errors$/ c += 1 if k =~ /^#{@name}\+/ end return c end |