123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475(** [with_retries ?retry_delay ?retry_cnt f] wraps deferred function [f] with
retry logic. If an exception is raise by [f], and the number of retries has
not exceeded [retry_cnt], the exception will be logged and [f] will be
invoked again after a span of [retry_delay] has elapsed.
If the function [f] fails to evaluate after [retry_cnt] iterations, the
final exception is reraised as is and nothing is logged. *)letwith_retries?(retry_delay:Time.Span.t=Time.Span.of_ms50.)?(retry_cnt:int=3)(f:unit->'aDeferred.t):'aDeferred.t=letrecretryn=try_withf>>=function|Result.Errore->(matchn>=retry_cntwith|true->raisee|false->Log.Global.debug"aws service operation failed (attempt %d/%d)"nretry_cnt;Clock.afterretry_delay>>=fun()->retry(n+1))|Result.Okok->returnokinretry0;;moduleCohttp:sigmoduleBody=Cohttp_async.BodymoduleCode=Cohttp.CodemoduleClient=Cohttp_async.ClientmoduleHeader=Cohttp.HeadermoduleRequest=Cohttp.RequestmoduleResponse=Cohttp_async.Responsevalto_meth:Awsm.Http.Meth.t->Cohttp.Code.methvalto_headers:Awsm.Http.Request.t->Cohttp.Header.tvalof_version:Cohttp.Response.t->int*intvalof_headers:Cohttp.Response.t->Awsm.Http.Headers.tvalof_status:Cohttp.Response.t->Awsm.Http.Status.tend=structmoduleBody=Cohttp_async.BodymoduleCode=Cohttp.CodemoduleClient=Cohttp_async.ClientmoduleHeader=Cohttp.HeadermoduleRequest=Cohttp.RequestmoduleResponse=Cohttp_async.Responseletto_methmeth=(meth:>Cohttp.Code.meth)letto_headersreq=req|>Awsm.Http.Request.headers|>Awsm.Http.Headers.to_list|>Cohttp.Header.of_list;;letof_versionresp=matchCohttp.Response.versionrespwith|`HTTP_1_0->1,0|`HTTP_1_1->1,1|`Other_->(* FIXME (dinosaure): should never occur! *)0,0;;letof_headersresp=resp|>Cohttp.Response.headers|>Cohttp.Header.to_list|>Awsm.Http.Headers.of_list;;letof_statusresp=matchCohttp.Response.statusrespwith|#Awsm.Http.Status.tasstatus->(status:>Awsm.Http.Status.t)|status->`Code(Cohttp.Code.code_of_statusstatus);;endmoduleCohttp_async=structend