go-libp2p-pubsub
go-libp2p-pubsub copied to clipboard
Allow Topics to close any handles they have
@Stebalien mentioned in https://github.com/libp2p/go-libp2p-pubsub-router/pull/37#discussion_r345971256 that the restrictions posed on closing a Topic handle shouldn't need to exist https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/topic.go#L187
IIUC the reasoning is that since only one valid Topic handle can exist for a given topic that when that handler calls Close() it is willing to kill any existing Subscription or TopicEventHandler objects that are outstanding.
This may clean up some code, by removing a bunch of error checking/handling, but comes at the cost of adding complexity for a Topic with N Subscriptions that only wants to close when all N Subscriptions are closed.
Both options are by me. WDYT @vyzo?
Maybe we can simply reference count the closures?
As we decided in https://github.com/libp2p/go-libp2p-pubsub/issues/198, topic handles are now owned by a single service. There shouldn't be any need to reference count unless I'm missing something.