let dbclient_rw = match data_rw.0.get().await {
Ok(c) => c,
Err(e) => {
log::error!("Pool RW error {}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let stmt = match dbclient_rw
.prepare("insert into games.players (game_uid, player_name, is_confirmed, species, client_type) values ($1, $2, true, 'RANDOM', 'p');")
.await
{
Ok(stmt) => stmt,
Err(e) => {
log::error!("Pool RW statement error {}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let inserted = match dbclient_rw
.execute(&stmt, &[&cached_data.0, &cached_data.1])
.await
{
Ok(c) => c,
Err(e) => {
log::error!("Pool RW execute insert error {}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
if inserted == 0 {
log::error!("Pool RW execute insert row error");
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}