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

Method WriteLoop

metrics/dogstatsd/dogstatsd.go:117–128  ·  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

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