From 444a7d796e3d1588425584b62d0616d8af47369f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20El=20Siba=C3=AFe?= Date: Wed, 14 Jun 2023 14:45:50 +0200 Subject: [PATCH] lib_rpc_http: expose RetryClient to enable overwriting - especially we want to access `ctx` parameter to be able to redirect client rpcs to a socket --- src/lib_rpc_http/RPC_client_unix.ml | 7 +++++-- src/lib_rpc_http/RPC_client_unix.mli | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib_rpc_http/RPC_client_unix.ml b/src/lib_rpc_http/RPC_client_unix.ml index be1d41413602..17201d84208c 100644 --- a/src/lib_rpc_http/RPC_client_unix.ml +++ b/src/lib_rpc_http/RPC_client_unix.ml @@ -54,7 +54,8 @@ module Attempt_logging = Internal_event.Make (struct let level = Internal_event.Error end) -module RetryClient : Cohttp_lwt.S.Client = struct +module RetryClient : + Cohttp_lwt.S.Client with type ctx = Cohttp_lwt_unix.Net.ctx = struct include Cohttp_lwt_unix.Client let clone_body = function `Stream s -> `Stream (Lwt_stream.clone s) | x -> x @@ -62,7 +63,9 @@ module RetryClient : Cohttp_lwt.S.Client = struct let call ?ctx ?headers ?body ?chunked meth uri = let rec call_and_retry_on_502 attempt delay = let open Lwt_syntax in - let* response, ansbody = call ?ctx ?headers ?body ?chunked meth uri in + let* response, ansbody = + Cohttp_lwt_unix.Client.call ?ctx ?headers ?body ?chunked meth uri + in let status = Cohttp.Response.status response in match status with | `Bad_gateway -> diff --git a/src/lib_rpc_http/RPC_client_unix.mli b/src/lib_rpc_http/RPC_client_unix.mli index 23d45509469e..0414afbb7132 100644 --- a/src/lib_rpc_http/RPC_client_unix.mli +++ b/src/lib_rpc_http/RPC_client_unix.mli @@ -23,4 +23,6 @@ (* *) (*****************************************************************************) +module RetryClient : Cohttp_lwt.S.Client with type ctx = Cohttp_lwt_unix.Net.ctx + include RPC_client.S -- GitLab