Closed arodland closed 7 years ago
@arodland Thank you for the report on this usability issue! Maybe we could change NewSubChanneler to:
func NewSubChanneler(endpoints string, subscribe ...string) *Channeler
Then, an empty string could keep the same functionality, and not passing a subscribe arg at all could create a SubChanneler that is not subscribed to anything.
Thank you. Yes, I think that's a good solution.
To prevent confusion, multiple values should also work, so that you could do NewSubChanneler(endpoint, "one", "two", "three")
in place of NewSubChanneler(endpoint, "one,two,three")
. Otherwise, someone will try it anyway :)
@arodland haha yeah - so you'll be able to pass nothing, or one or more topics, and an empty string topic will be treated as "all" as it is now.
@arodland ok - the change is merged on master, thanks again for the feedback.
v4 added the ability to call
Subscribe
andUnsubscribe
on aSubChanneler
at runtime, which is great. But the case where you have no subscriptions to begin with, and add them on demand, isn't handled very well. IfNewSubChanneler
is called with an empty string as a subscription list it will subscribe to everything, there's no way to subscribe to nothing.It's possible to work around this by calling
.Unsubscribe("")
right afterwards, but that's racy.It's possible to work around it by passing some very improbable topic name as the initial subscription, but that's messy.