benashford / redis-async-rs

A Rust client for Redis, using Tokio
Apache License 2.0
253 stars 30 forks source link

PubsubStream Drop impl Calls Unsubscribe #84

Closed kalkronline closed 1 year ago

kalkronline commented 1 year ago

I've applied a bandaid in my fork to remove this drop:

https://github.com/benashford/redis-async-rs/blob/d2c4b19fca8d2f82248fd36948a6ee0fbf874463/src/client/pubsub.rs#L484-L489

as it is inappropriate for pattern subscriptions and cases where I want to manage the unsubscription myself.

Additionally, (and more importantly) calling unsubscribe twice for the same channel will cause all streams to silently fail.

benashford commented 1 year ago

Thanks for this. The intention here is to make streams compatible with Rust idioms by not requiring specific functions like unsubscribe. However if both are used then an error will occur when the second attempt at unsubscribing is acknowledged.

Which is obviously unhelpful.

Since Redis itself seems not to mind if unsubscribed is called twice, then neither should we. This will solve that problem and allow both the explicit call to unsubscribe and the Drop implementation.

benashford commented 1 year ago

This should now be fixed in version 0.15