#multiple backend clients of the same type

1 messages · Page 1 of 1 (latest)

polar ore
#

Curious, is there a simple way to differentiate between clients if you per say are adding 2 mongo servers

App::new()
.app_data(web::Data::new(mongo_client.clone()))
.app_data(web::Data::new(mongo_client2.clone()))

Later on what is the preferred method to take care / loop through these clients or only specify one or the other?

async fn mongo_test(client: web::Data<Client>) -> HttpResponse {
//... do something against 1 or both DB's?
}

This is mainly a curiosity question, I'm not sure if I'll actually ever do this.

mighty sand
#

app data of the same type will override the earlier registration