bikeshedder / deadpool

Dead simple pool implementation for rust with async-await
Apache License 2.0
1.08k stars 137 forks source link

Support for read_from_replicas option in deadpool_redis #350

Closed fruscianteee closed 2 months ago

fruscianteee commented 2 months ago

Hello,

I'm currently using the redis-rs crate, which provides a read_from_replicas option. When this option is enabled, read queries will be sent to the replica nodes, while write queries will be sent to the primary nodes.

I would like to know if there is a way to enable the read_from_replicas option when using deadpool_redis. If this feature is not currently supported, are there any plans to add support for it in the future?

Thank you for your assistance.

bikeshedder commented 2 months ago

I don't run a redis cluster myself. Do you just need to call read_from_replicas() on the builder or is there any extra configuration that needs to be done?

I'm always happy to accept PRs if you want to implement this yourself.

fruscianteee commented 2 months ago

I believe it can be enabled with something like this:

let client = ClusterClientBuilder::new()
    .read_from_replicas()
    .build()?;

So, simply calling it on the builder should be sufficient.

I'm always happy to accept PRs if you want to implement this yourself.

Thank you for the opportunity. This would be my first contribution, but I'd like to give it a try. I'll review the source code in deadpool/redis/src/cluster and come up with a proposal for the changes.

fruscianteee commented 2 months ago

Thank you for reviewing the PR. It was a great experience, and I really enjoyed it. I’ll be happy to contribute again if there’s anything else in the future.

With that, I’d like to close this issue.

bikeshedder commented 2 months ago

I just published deadpool-redis 0.17.0 on crates.io including your changes:

Thanks a lot!