Module: Qup::TopicAPI
- Included in:
- Adapter::Kestrel::Topic, Adapter::Maildir::Topic, Adapter::Redis::Topic
- Defined in:
- lib/qup/topic_api.rb
Overview
Public: A TopicAPI for use in a publish-subscribe Messaging
The Topic delivers each Message that it is give to each and every Subscriber
This API MUST be implemented in each Adapter
Example:
session = Qup::Session.new( uri )
topic = session.topic( 'news' )
pub = topic.publisher
sub1 = topic.subscriber( 'sub1' )
sub2 = topic.subscriber( 'sub2' )
pub.publish( 'some news' )
= sub1.consume
= sub2.consume
Instance Method Summary collapse
-
#destroy ⇒ Object
Public: destroy the Topic if possible.
-
#name ⇒ Object
Public: the name of the Topic.
-
#publish(message) ⇒ Object
Internal: Publish a Message to all the Subscribers.
-
#publisher ⇒ Object
Public: Creates a Publisher for the Topic.
-
#subscriber(name) ⇒ Object
Public: Create a subscriber for the Topic.
-
#subscriber_count ⇒ Object
Public: Return the number of Subscribers to this Topic.
Instance Method Details
#destroy ⇒ Object
Public: destroy the Topic if possible
This will remove the Topic from the system if possible
Returns nothing.
68 69 70 71 72 |
# File 'lib/qup/topic_api.rb', line 68 def destroy super rescue NoMethodError raise NotImplementedError, "please implement 'destroy'" end |
#name ⇒ Object
Public: the name of the Topic
Returns the String name
56 57 58 59 60 |
# File 'lib/qup/topic_api.rb', line 56 def name super rescue NoMethodError raise NotImplementedError, "please implement 'name'" end |
#publish(message) ⇒ Object
Internal: Publish a Message to all the Subscribers
message - the Object to send to all subscribers
Returns nothing
88 89 90 |
# File 'lib/qup/topic_api.rb', line 88 def publish( ) raise NotImplementedError, "please implement 'publish'" end |
#publisher ⇒ Object
Public: Creates a Publisher for the Topic
Returns a new Publisher
32 33 34 |
# File 'lib/qup/topic_api.rb', line 32 def publisher raise NotImplementedError, "please implement 'publisher'" end |
#subscriber(name) ⇒ Object
Public: 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
48 49 50 |
# File 'lib/qup/topic_api.rb', line 48 def subscriber( name ) raise NotImplementedError, "please implement 'subscriber'" end |
#subscriber_count ⇒ Object
Public: Return the number of Subscribers to this Topic
Returns integer
78 79 80 |
# File 'lib/qup/topic_api.rb', line 78 def subscriber_count raise NotImplementedError, "please implement 'subscriber_count'" end |