MCPcopy
hub / github.com/grafana/dskit / WithFlushPeriod

Function WithFlushPeriod

log/buffered.go:70–81  ·  view source on GitHub ↗

WithFlushPeriod creates a new BufferedLoggerOption that sets the flush period for the BufferedLogger.

(d time.Duration)

Source from the content-addressed store, hash-verified

68
69// WithFlushPeriod creates a new BufferedLoggerOption that sets the flush period for the BufferedLogger.
70func WithFlushPeriod(d time.Duration) BufferedLoggerOption {
71 return func(l *BufferedLogger) {
72 go func() {
73 tick := time.NewTicker(d)
74 defer tick.Stop()
75
76 for range tick.C {
77 l.Flush()
78 }
79 }()
80 }
81}
82
83// WithFlushCallback allows for a callback function to be executed when Flush() is called.
84// The length of the buffer at the time of the Flush() will be passed to the function.

Callers 2

BenchmarkBufferedFunction · 0.85
TestBufferedConcurrencyFunction · 0.85

Calls 2

StopMethod · 0.65
FlushMethod · 0.65

Tested by 2

BenchmarkBufferedFunction · 0.68
TestBufferedConcurrencyFunction · 0.68