func (rc *RequestCounter) watch() {
	go func() {
		for {
			rc.Cycle()
		}
	}()
}
watch indefinitely performs repeated sleep/log cycles.
package reqcounter
import (
	"fmt"
	"sync"
	"time"
	"github.com/sirupsen/logrus"
	tw "sigs.k8s.io/promo-tools/v3/legacy/timewrapper"
)
type RequestCounter struct {
	Mutex     sync.Mutex     
	Requests  uint64         
	Since     time.Time      
	Interval  time.Duration  
	Threshold uint64         
}
func (rc *RequestCounter) Increment() {
	rc.Mutex.Lock()
	rc.Requests++
	rc.Mutex.Unlock()
}
func (rc *RequestCounter) Flush() {
	rc.Mutex.Lock()
	defer rc.Mutex.Unlock()
	rc.log()
	if rc.Threshold > 0 {
		rc.reset()
	}
}
func (rc *RequestCounter) log() {
	msg := fmt.Sprintf("From %s to %s [%d min] there have been %d requests to GCR.", rc.Since.Format(TimestampFormat), Clock.Now().Format(TimestampFormat), rc.Interval/time.Minute, rc.Requests)
	Debug(msg)
	if rc.Threshold > 0 && rc.Requests > rc.Threshold {
		msg = fmt.Sprintf("The threshold of %d requests has been surpassed.", rc.Threshold)
		Warn(msg)
	}
}
func (rc *RequestCounter) reset() {
	rc.Requests = 0
	rc.Since = Clock.Now()
}