TCP/TLS connection pooling for Eio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): resolve E005 long functions in conpool and cpio

- conpool: extract wait_for_available_slot from acquire_connection
- cpio: extract read_name_and_data from read_entry

+18 -20
+18 -20
lib/conpool.ml
··· 428 428 pool.protocol.on_acquire conn.pc_state; 429 429 conn 430 430 431 + let wait_for_available_slot pool ep_pool endpoint = 432 + let wait_conn = 433 + List.find_opt 434 + (fun c -> 435 + match pool.protocol.access_mode c.pc_state with 436 + | Config.Shared _ -> true 437 + | Config.Exclusive -> false) 438 + !(ep_pool.connections) 439 + in 440 + match wait_conn with 441 + | Some conn -> wait_for_shared_slot pool ep_pool conn endpoint 442 + | None -> 443 + let any_conn = List.hd !(ep_pool.connections) in 444 + wait_for_exclusive_slot pool ep_pool any_conn endpoint 445 + 431 446 let rec acquire_connection pool ep_pool endpoint = 432 447 Eio.Mutex.use_rw ~protect:true ep_pool.ep_mutex (fun () -> 433 448 let rec find_available = function ··· 465 480 Log.debug (fun m -> 466 481 m "At connection limit for %a (%d), waiting..." Endpoint.pp 467 482 endpoint max_conns); 468 - let wait_conn = 469 - List.find_opt 470 - (fun c -> 471 - match pool.protocol.access_mode c.pc_state with 472 - | Config.Shared _ -> true 473 - | Config.Exclusive -> false) 474 - !(ep_pool.connections) 475 - in 476 - match wait_conn with 477 - | Some conn -> ( 478 - match wait_for_shared_slot pool ep_pool conn endpoint with 479 - | Some conn -> conn 480 - | None -> acquire_connection pool ep_pool endpoint) 481 - | None -> ( 482 - let any_conn = List.hd !(ep_pool.connections) in 483 - match 484 - wait_for_exclusive_slot pool ep_pool any_conn endpoint 485 - with 486 - | Some conn -> conn 487 - | None -> acquire_connection pool ep_pool endpoint) 483 + match wait_for_available_slot pool ep_pool endpoint with 484 + | Some conn -> conn 485 + | None -> acquire_connection pool ep_pool endpoint 488 486 end 489 487 else new_connection pool ep_pool endpoint) 490 488