Hcs.Plug.Circuit_breaker

hcs · API reference

type circuit_state = 
  | Closed
  | Open of float
  | Half_open
type t = {
  state : circuit_state Kcas.Loc.t;
  failure_count : int Kcas.Loc.t;
  failure_threshold : int;
  reset_timeout : float;
  success_count : int Kcas.Loc.t;
  success_threshold : int;
}
val make : 
  ?failure_threshold:int ->
  ?reset_timeout:float ->
  ?success_threshold:int ->
  unit ->
  t
val allow : xt:'a Kcas.Xt.t -> t -> now:float -> bool
val record_success : xt:'a Kcas.Xt.t -> t -> unit
val record_failure : xt:'a Kcas.Xt.t -> t -> now:float -> unit
val create : 
  clock:[> float Eio.Time.clock_ty ] Eio.Time.clock ->
  ?on_open:(Server.request -> Response.t) ->
  t ->
  (Server.request -> Server.response) ->
  Server.request ->
  Server.response