updated comments of throttler
This commit is contained in:
parent
f3963288e3
commit
0801310542
@ -6,6 +6,10 @@ import (
|
|||||||
|
|
||||||
// Throttling notifications to prometheus and web clients
|
// Throttling notifications to prometheus and web clients
|
||||||
// TO be used in a single-threaded manner.
|
// 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 {
|
type Throttler[T comparable] struct {
|
||||||
minDelay time.Duration
|
minDelay time.Duration
|
||||||
// ucntion to call to implement the notification.
|
// 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.
|
// notification was sent is long enough ago.
|
||||||
func (throttler *Throttler[T]) Ping() {
|
func (throttler *Throttler[T]) Ping() {
|
||||||
if throttler.pendingValue != *new(T) {
|
if throttler.pendingValue != *new(T) {
|
||||||
// TODO improve: use a better way to recognize that there is a pending value.
|
|
||||||
throttler.Notify(throttler.pendingValue)
|
throttler.Notify(throttler.pendingValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user