Commit graph

6 commits

Author SHA1 Message Date
David Calavera
a72c316bf4 Add PubSub topics.
A TopicFunc is an interface to let the pubisher decide whether it needs
to send a message to a subscriber or not. It returns true if the
publisher must send the message and false otherwise.

Users of the pubsub package can create a subscriber with a topic
function by calling `pubsub.SubscribeTopic`.

Message delivery has also been modified to use concurrent channels per
subscriber. That way, topic verification and message delivery is not
o(N+M) anymore, based on the number of subscribers and topic verification
complexity.

Using pubsub topics, the API stops controlling the message delivery,
delegating that function to a topic generated with the filtering
provided by the user. The publisher sends every message to the
subscriber if there is no filter, but the api doesn't have to select
messages to return anymore.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-02 16:43:49 -05:00
Alexander Morozov
d5b7b9fa88 Don't use time.After if there is no timeout
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-07-14 09:14:51 -07:00
Alexander Morozov
879a1a6842 Add docstring to pubsub.Publisher
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-07-14 09:10:14 -07:00
Chun Chen
33cd97fb23 Fix send on closed channel bug
Signed-off-by: Chun Chen <chenchun.feed@gmail.com>
2015-06-12 15:42:34 +08:00
Michael Crosby
a96214b8c6 Remove publisher if no one is listening
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-20 20:21:47 -08:00
Michael Crosby
eff8e3294c Add pubsub package to handle robust publisher
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-20 20:21:46 -08:00