From 11e90ac604d15f774eb5bf74a3f36ce3778fa613 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Jan 2019 11:46:48 +0200 Subject: [PATCH 1/2] document subscribe's non instanteneous semantics --- pubsub.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pubsub.go b/pubsub.go index ebb2dcc..e78b4bc 100644 --- a/pubsub.go +++ b/pubsub.go @@ -718,14 +718,16 @@ type addSubReq struct { type SubOpt func(sub *Subscription) error -// Subscribe returns a new Subscription for the given topic +// Subscribe returns a new Subscription for the given topic. +// Note that subscription is not an instanteneous operation. It may take some time +// before the subscription is processed by the pubsub main loop and propagated to our peers. func (p *PubSub) Subscribe(topic string, opts ...SubOpt) (*Subscription, error) { td := pb.TopicDescriptor{Name: &topic} return p.SubscribeByTopicDescriptor(&td, opts...) } -// SubscribeByTopicDescriptor lets you subscribe a topic using a pb.TopicDescriptor +// SubscribeByTopicDescriptor lets you subscribe a topic using a pb.TopicDescriptor. func (p *PubSub) SubscribeByTopicDescriptor(td *pb.TopicDescriptor, opts ...SubOpt) (*Subscription, error) { if td.GetAuth().GetMode() != pb.TopicDescriptor_AuthOpts_NONE { return nil, fmt.Errorf("auth mode not yet supported") From 41306ab374c88dc3e8c4fc750449190c9fa64046 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Jan 2019 11:47:06 +0200 Subject: [PATCH 2/2] move package declaration after documentation so that it is rendered by godoc --- doc.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc.go b/doc.go index fa0d7e1..555285b 100644 --- a/doc.go +++ b/doc.go @@ -1,5 +1,3 @@ -package pubsub - // The pubsub package provides facilities for the Publish/Subscribe pattern of message // propagation, also known as overlay multicast. // The implementation provides topic-based pubsub, with pluggable routing algorithms. @@ -23,3 +21,4 @@ package pubsub // // To subscribe to a topic, use `Subscribe`; this will give you a subscription interface // from which new messages can be pumped. +package pubsub