diff --git a/src/client/batch.ml b/src/client/batch.ml index 600f1b43..005644c2 100644 --- a/src/client/batch.ml +++ b/src/client/batch.ml @@ -7,14 +7,15 @@ type 'a t = { mutable start: Mtime.t; } -let make ?(batch = 1) ?timeout () : _ t = +let high_watermark batch_size = + if batch_size = 1 then + 100 + else + batch_size * 10 + +let make ?(batch = 1) ?(high_watermark = high_watermark batch) ?timeout () : _ t + = assert (batch > 0); - let high_watermark = - if batch = 1 then - 100 - else - batch * 10 - in { size = 0; start = Mtime_clock.now (); diff --git a/src/client/batch.mli b/src/client/batch.mli index 37b12857..39fdd4d4 100644 --- a/src/client/batch.mli +++ b/src/client/batch.mli @@ -2,15 +2,20 @@ type 'a t -val make : ?batch:int -> ?timeout:Mtime.span -> unit -> 'a t +val make : + ?batch:int -> ?high_watermark:int -> ?timeout:Mtime.span -> unit -> 'a t (** [make ()] is a new batch @param batch the number of elements after which the batch will be considered {b full}, - and ready to pop. A "high water mark" is also derived form the batch as - [if batch = 1 then 100 else batch * 10]. This sets a limit after which new - elements will be [`Dropped] by {!push}. Set to [0] to disable batching. - Default [1]. + and ready to pop. Set to [0] to disable batching. It is required that + [batch >= 0]. Default [1]. + + @param high_watermark + the batch size limit after which new elements will be [`Dropped] by + {!push}. This prevents the queue from growing too fast for effective + transmission in case of signal floods. Default + [if batch = 1 then 100 else batch * 10]. @param timeout the time span after which a batch is ready to pop, whether or not it is