Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe to a topic multiple times #10

Merged
merged 12 commits into from
Nov 21, 2016

Conversation

keks
Copy link
Contributor

@keks keks commented Oct 20, 2016

This PR basically does what I explained here. I rebased everything so that it is easily mergable. Yay!

@keks
Copy link
Contributor Author

keks commented Oct 20, 2016

paging @whyrusleeping

@keks
Copy link
Contributor Author

keks commented Nov 10, 2016

CR please :)

for t := range p.myTopics {
out = append(out, t)
for t, subs := range p.myTopics {
if len(subs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this ever not be > 0? That seems like it could end up being a memory leak

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just searched for occurences of myTopics and it seems there is no way that it's empty. I'll just drop the check. Thanks!

func (p *PubSub) GetTopics() []string {
out := make(chan []string, 1)
p.getTopics <- &topicReq{resp: out}
return <-out
}

func (p *PubSub) SubscribeComplicated(td *pb.TopicDescriptor) (<-chan *Message, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the topic descriptors. They arent super used yet, but thats the next step for this impl.

@whyrusleeping
Copy link
Contributor

@keks the approach looks good to me, i'd like to see some new tests exercising that behaviour from a users perspective though (as in, how a consumer would use multiple subscriptions)

@keks
Copy link
Contributor Author

keks commented Nov 11, 2016

@whyrusleeping there you go!

@keks
Copy link
Contributor Author

keks commented Nov 11, 2016

I added the test showcasing that you can now subscribe to one topic multiple times. I guess in the test it doesn't look very impressing, but in the ipfs daemon it's important we can do that because the might be pubsub clients that subscribe to the same topic but don't even know about each other.

resp chan []string
}
// Subscribe returns a new Subscription for the given topic
func (p *PubSub) Subscribe(topic string) *Subscription {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ensure that all subscribe calls go through SubscribeByTopicDescriptor, it will make things easier on us moving forward

@whyrusleeping
Copy link
Contributor

@keks fantastic, thank you! One more comment and then LGTM

@keks
Copy link
Contributor Author

keks commented Nov 11, 2016

Done.

Note this introduces an API change since Subscribe() will now also return an error (the error returned from SubscribeByTopicDescriptor()). At the moment these errors could be ignored because they will not happen anyway, but that didn't seem right to me as a long-term strategy. I you want I can panic instead.

@keks
Copy link
Contributor Author

keks commented Nov 13, 2016

There you go...

@keks
Copy link
Contributor Author

keks commented Nov 17, 2016

I rebased and added the context to Subsciption.Next() so it can be cancelled.

@whyrusleeping
Copy link
Contributor

I'm ready to merge this, just gotta catch it right after youve rebased.

@keks keks force-pushed the feat/feed-refactor branch from 37c35e0 to 21adc8d Compare November 18, 2016 01:24
@keks
Copy link
Contributor Author

keks commented Nov 18, 2016

sigh I'll figure it out eventually...

@keks
Copy link
Contributor Author

keks commented Nov 19, 2016

actually I don't get the problem. The builders complain they can't find the libp2p gx dependency, but that change happened in c0c5a38. The tests don't even start. Can you kick it so it tries again @whyrusleeping?

@Kubuxu
Copy link
Member

Kubuxu commented Nov 19, 2016

@keks I think that his package might have been moved to: https://github.com/libp2p/go-libp2p-netutil

@Kubuxu
Copy link
Member

Kubuxu commented Nov 19, 2016

And it might have been my fail on not fixing this up before updating the dep.

@whyrusleeping
Copy link
Contributor

@keks use QmcDTquYLTYirqj71RRWKUWEEw3nJt11Awzun5ep8kfY7W for go-netutil, I was in the middle of updating a few things and havent gotten to bubbling them up entirely. (i think)

@whyrusleeping
Copy link
Contributor

You can also give me push access to this branch and i can fix it (alternatively, why are you not a contributor yet? let me fix that)

@keks
Copy link
Contributor Author

keks commented Nov 19, 2016

🎉

@keks keks mentioned this pull request Nov 21, 2016
@keks
Copy link
Contributor Author

keks commented Nov 21, 2016

Tests pass, no conflicts and gx published...I guess this means ready to merge? What do you think @whyrusleeping?

@whyrusleeping whyrusleeping merged commit c3de971 into libp2p:master Nov 21, 2016
@keks keks mentioned this pull request Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants