clj-commons / manifold

A compatibility layer for event-driven abstractions
1.02k stars 108 forks source link

batch with metric can exceed max-size #75

Closed hadronzoo closed 8 years ago

hadronzoo commented 8 years ago

I'm trying to use max-size with metric to limit the total number of bytes in a batch, but the resulting batches are exceeding the specified max-size. Rather than limiting the cumulative batch size, it seems that the max-size argument acts more like a trigger, sending messages once the accumulated message size is greater than or equal to max-size.

For example:

(def sink (s/stream))
(def source (s/batch (constantly 7) 8 10000 sink))

(dotimes [_ 10] (s/put! sink 7))
@(s/take! source)
;; => [7 7]