TCP/TLS connection pooling for Eio
at main 1.0 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Network endpoint representation *) 7 8let src = 9 Logs.Src.create "conpool.endpoint" ~doc:"Connection pool endpoint operations" 10 11module Log = (val Logs.src_log src : Logs.LOG) 12 13type t = { host : string; port : int } 14 15let make ~host ~port = 16 (* Validate port range *) 17 if port < 1 || port > 65535 then 18 invalid_arg 19 (Printf.sprintf "Invalid port number: %d (must be 1-65535)" port); 20 21 (* Validate hostname is not empty *) 22 if String.trim host = "" then invalid_arg "Hostname cannot be empty"; 23 24 { host; port } 25 26let host t = t.host 27let port t = t.port 28let equal t1 t2 = String.equal t1.host t2.host && t1.port = t2.port 29let hash t = Hashtbl.hash (t.host, t.port) 30let pp = Fmt.of_to_string (fun t -> Printf.sprintf "%s:%d" t.host t.port)