Pass redis ConnectionManager as an option to a async function


I suppose that the topic might be bit confusing, what I'd like to do, in general, have a option to enable/disable Redis in being used.

The code is setup that from main async I call join two different functions, and pass the redis::aio::ConnectionManager to them to use in their logic.
Mock code would be this:

async fn main() {
  let redis = redis_cache::connection("config").await.unwap();

tokio::join!(http_listener(redis.clone()), https_listener(redis.clone());

I'd like to have a config toggle option (bool) if it's true, then I establish the redis connection and pass it along, but if it's false, I pass... ? And this is where I'm at now.

I am thinking of wrapping it in an Option and then check in the logic for Option return and continue with the logic.

I wanted to ask for guidance how to correctly approach this.

Thank you for your time!

Managed to pass it as part of the Option and get the logic sorted with matching Some/None.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.