From 416acc6fc445b823a1822a0e20b4b9ee8b71628f Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Tue, 9 Jul 2024 12:26:41 +0100 Subject: [PATCH] Comments --- storage/queue.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/storage/queue.go b/storage/queue.go index d70f745b9..6b31f2f87 100644 --- a/storage/queue.go +++ b/storage/queue.go @@ -23,9 +23,17 @@ import ( "github.com/globocom/go-buffer" ) -// Queue knows how to queue up a number of entries before calling a FlushFunc with -// a slice of all queued entries, in the same order as they were added, after either -// a defined period of time has passed, or a defined number of entries were added. +// Queue knows how to queue up a number of entries in order, taking care of deduplication as they're added. +// +// When the buffered queue grows past a defined size, or the age of the oldest entry in the +// queue reaches a defined threshold, the queue will call a provided FlushFunc with +// a slice containing all queued entries in the same order as they were added. +// +// If multiple identical entries are added to the queue between flushes, the queue will deduplicate them by +// passing only the first through to the FlushFunc, and returning the index assigned to that entry to all +// duplicate add calls. +// Note that this deduplication only applies to "in-flight" entries currently in the queue; entries added +// after a flush will not be deduped against those added before the flush. type Queue struct { buf *buffer.Buffer flush FlushFunc