MCPcopy
hub / github.com/go-kit/kit / WriteLoop

Method WriteLoop

metrics/influxstatsd/influxstatsd.go:116–127  ·  view source on GitHub ↗

WriteLoop is a helper method that invokes WriteTo to the passed writer every time the passed channel fires. This method blocks until ctx is canceled, so clients probably want to run it in its own goroutine. For typical usage, create a time.Ticker and pass its C channel to this method.

(ctx context.Context, c <-chan time.Time, w io.Writer)

Source from the content-addressed store, hash-verified

114// so clients probably want to run it in its own goroutine. For typical
115// usage, create a time.Ticker and pass its C channel to this method.
116func (d *Influxstatsd) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer) {
117 for {
118 select {
119 case <-c:
120 if _, err := d.WriteTo(w); err != nil {
121 d.logger.Log("during", "WriteTo", "err", err)
122 }
123 case <-ctx.Done():
124 return
125 }
126 }
127}
128
129// SendLoop is a helper method that wraps WriteLoop, passing a managed
130// connection to the network and address. Like WriteLoop, this method blocks

Callers 1

SendLoopMethod · 0.95

Calls 2

WriteToMethod · 0.95
LogMethod · 0.45

Tested by

no test coverage detected