new implementation for ocurl backend, using ezcurl and queues

This commit is contained in:
Simon Cruanes 2023-06-16 22:57:54 -04:00
parent b5c0ef7b20
commit 832113fe02
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
5 changed files with 380 additions and 636 deletions

24
src/client-ocurl/batch.ml Normal file
View file

@ -0,0 +1,24 @@
type 'a t = {
mutable len: int;
mutable l: 'a list list;
mutable started: Mtime.t;
}
let create () = { len = 0; l = []; started = Mtime_clock.now () }
let push self l =
if l != [] then (
if self.l == [] then self.started <- Mtime_clock.now ();
self.l <- l :: self.l;
self.len <- self.len + List.length l
)
let len self = self.len
let time_started self = self.started
let pop_all self =
let l = self.l in
self.l <- [];
self.len <- 0;
l

View file

@ -0,0 +1,14 @@
(** List of lists with length *)
type 'a t
val create : unit -> 'a t
val push : 'a t -> 'a list -> unit
val len : _ t -> int
val time_started : _ t -> Mtime.t
(** Time at which the batch most recently became non-empty *)
val pop_all : 'a t -> 'a list list

View file

@ -18,10 +18,6 @@ let pp out self =
debug url ppheaders headers batch_timeout_ms bg_threads
let make ?(debug = !debug_) ?(url = get_url ()) ?(headers = get_headers ())
?(batch_timeout_ms = 500) ?bg_threads () : t =
let bg_threads =
match bg_threads with
| Some n -> max n 2
| None -> 4
in
?(batch_timeout_ms = 500) ?(bg_threads = 4) () : t =
let bg_threads = max 2 (min bg_threads 32) in
{ debug; url; headers; batch_timeout_ms; bg_threads }

View file

@ -1,3 +1,5 @@
(** Configuration for the ocurl backend *)
type t = private {
debug: bool;
url: string;

File diff suppressed because it is too large Load diff