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

Method WriteLoop

metrics/graphite/graphite.go:90–101  ·  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

88// so clients probably want to run it in its own goroutine. For typical
89// usage, create a time.Ticker and pass its C channel to this method.
90func (g *Graphite) WriteLoop(ctx context.Context, c <-chan time.Time, w io.Writer) {
91 for {
92 select {
93 case <-c:
94 if _, err := g.WriteTo(w); err != nil {
95 g.logger.Log("during", "WriteTo", "err", err)
96 }
97 case <-ctx.Done():
98 return
99 }
100 }
101}
102
103// SendLoop is a helper method that wraps WriteLoop, passing a managed
104// 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