Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use bb8 with redis pubsub connections ? #70

Open
sync opened this issue May 21, 2020 · 10 comments
Open

How to use bb8 with redis pubsub connections ? #70

sync opened this issue May 21, 2020 · 10 comments

Comments

@sync
Copy link

sync commented May 21, 2020

First of all thank you for the recent update to bb8 :-)

I can never turn a conn in into a pubsub connection calling into_pubsub for some reason. Have you had a chance to have a look pubsub with redis ?

let mut conn = pool.get().await.unwrap();
let conn = conn.as_mut().unwrap();

From redis

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let mut publish_conn = client.get_async_connection().await?;
let mut pubsub_conn = client.get_async_connection().await?.into_pubsub();
@sync
Copy link
Author

sync commented May 21, 2020

I hacked around it but it is definitely not a good solution:

https://github.com/sync/bb8/commit/876ed2c2b2b7d94922c83c1d87e69c3569341640

@djc
Copy link
Owner

djc commented May 22, 2020

Having a second pool for this doesn't seem so bad. Why do you think it's not a good solution?

@khuey
Copy link
Collaborator

khuey commented May 22, 2020

Can you get yourself a dedicated connection (via Pool<M>::dedicated_connection) and use that? I'm not entirely sure how Redis's pub-sub stuff works but I added that for doing LISTENs on postgres.

@sync
Copy link
Author

sync commented May 23, 2020

I didn't like the fact that i have to create a fake subscription to see if pool is working... I've opened a PR let me know what you think:
#71

@sync
Copy link
Author

sync commented May 23, 2020

@khuey i can't see any usage of the dedicated_connection in the codebase, do you have a sample somewhere ?

@djc
Copy link
Owner

djc commented May 25, 2020

Pool::dedicated_connection() is a simple method on the Pool that uses the address/authentication information contained in the Pool's ConnectionManager to build a new connection, and then directly yields that connection to the caller. I think it would make sense to use for this (as discussed in #71 as well).

@bbaldino
Copy link

bbaldino commented May 3, 2023

@djc might you be open to supporting a pubsub connection pool? The changes to do so seem pretty minimal (still need to figure out what is_valid should look like there).

My usecase for it is that we're looking to use an adhoc pubsub channel to send back a response from a request received over a stream. Using a stream for the response is overkill because we want this to be ephemeral.

@djc
Copy link
Owner

djc commented May 15, 2023

@bbaldino I'll consider it, please submit a PR.

@bbaldino
Copy link

Thanks @djc. Opened #159

@nihohit
Copy link

nihohit commented Dec 3, 2024

Hi,If this is still an issue, I recommend using RESP3 pubsub. It allows to use the same connection for pubsub & for regular usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants