cetra3/tmq

Calling subscribe multiple times doesn't seem possible

Closed this issue · 2 comments

I know with plain zmq it is possible to have multiple subscriptions, but I suppose here it is not possible?

For example:

let mut socket = subscribe(&Context::new())
    .connect("tcp://127.0.0.1:7899")?
    .subscribe(b"topic")?
    .subscribe(b"topic2")?;

Basically would like to loop over a vec of topics and subscribe to those specific ones (rather than subscribing to all, i.e. b"")

After one subscribe the SubscribeWithoutTopic changes into Subscribe whereas the latter cannot do more subscriptions?

Good catch, we may need to rework the subscribe API to make this possible, maybe even have the subscribe function accept an iterator or similar. Open to PRs!

Thanks!

Actually in the end it was simply possible using:

for topic in &topics {
    socket.subscribe(topic)?;
}