From 0801310542387aaf01a33150403b3c8abfcde0b2 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 24 Aug 2024 22:47:51 +0200 Subject: [PATCH] updated comments of throttler --- pkg/support/throttling/throttler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/support/throttling/throttler.go b/pkg/support/throttling/throttler.go index f8e94e9..04b6b37 100644 --- a/pkg/support/throttling/throttler.go +++ b/pkg/support/throttling/throttler.go @@ -6,6 +6,10 @@ import ( // Throttling notifications to prometheus and web clients // TO be used in a single-threaded manner. +// +// NOTE: the null value of type T is considered as a not-set value. +// +// The best usage of Throttler is with a pointer type. type Throttler[T comparable] struct { minDelay time.Duration // ucntion to call to implement the notification. @@ -49,7 +53,6 @@ func (throttler *Throttler[T]) Notify(value T) { // notification was sent is long enough ago. func (throttler *Throttler[T]) Ping() { if throttler.pendingValue != *new(T) { - // TODO improve: use a better way to recognize that there is a pending value. throttler.Notify(throttler.pendingValue) } }