@@ -846,49 +846,52 @@ pub async fn lbheartbeat(req: HttpRequest) -> Result<HttpResponse, ApiError> {
846846 let db_state = if cfg ! ( test) {
847847 use actix_web:: http:: header:: HeaderValue ;
848848 use std:: str:: FromStr ;
849- use syncstorage_db:: PoolState ;
850-
851- PoolState {
852- connections : u32:: from_str (
853- req. headers ( )
854- . get ( "TEST_CONNECTIONS" )
855- . unwrap_or ( & HeaderValue :: from_static ( "0" ) )
856- . to_str ( )
857- . unwrap_or ( "0" ) ,
858- )
859- . unwrap_or_default ( ) ,
860- idle_connections : u32:: from_str (
861- req. headers ( )
862- . get ( "TEST_IDLES" )
863- . unwrap_or ( & HeaderValue :: from_static ( "0" ) )
864- . to_str ( )
865- . unwrap_or ( "0" ) ,
866- )
867- . unwrap_or_default ( ) ,
849+
850+ let size = usize:: from_str (
851+ req. headers ( )
852+ . get ( "TEST_CONNECTIONS" )
853+ . unwrap_or ( & HeaderValue :: from_static ( "0" ) )
854+ . to_str ( )
855+ . unwrap_or ( "0" ) ,
856+ )
857+ . unwrap_or_default ( ) ;
858+ let available = usize:: from_str (
859+ req. headers ( )
860+ . get ( "TEST_IDLES" )
861+ . unwrap_or ( & HeaderValue :: from_static ( "0" ) )
862+ . to_str ( )
863+ . unwrap_or ( "0" ) ,
864+ )
865+ . unwrap_or_default ( ) ;
866+ deadpool:: Status {
867+ max_size : size,
868+ size,
869+ available,
870+ waiting : 0 ,
868871 }
869872 } else {
870- state. db_pool . clone ( ) . state ( )
873+ state. db_pool . status ( )
871874 } ;
872875
873- let active = db_state. connections - db_state. idle_connections ;
876+ let active = db_state. size - db_state. available ;
874877 let mut status_code = StatusCode :: OK ;
875878
876- if active >= deadman. max_size && db_state. idle_connections == 0 {
879+ if active >= deadman. max_size as usize && db_state. available == 0 {
877880 if deadman. clock_start . is_none ( ) {
878881 deadman. clock_start = Some ( Instant :: now ( ) ) ;
879882 }
880883 status_code = StatusCode :: INTERNAL_SERVER_ERROR ;
881884 } else if deadman. clock_start . is_some ( ) {
882885 deadman. clock_start = None
883886 }
884- deadman. previous_count = db_state. idle_connections as usize ;
887+ deadman. previous_count = db_state. available ;
885888 {
886889 * deadarc. write ( ) . await = deadman;
887890 }
888891 resp. insert ( "active_connections" . to_string ( ) , Value :: from ( active) ) ;
889892 resp. insert (
890893 "idle_connections" . to_string ( ) ,
891- Value :: from ( db_state. idle_connections ) ,
894+ Value :: from ( db_state. available ) ,
892895 ) ;
893896 if let Some ( clock) = deadman. clock_start {
894897 let duration: Duration = Instant :: now ( ) - clock;
0 commit comments