resyncChan returns a channel which will receive something when a resync is required, and a cleanup function.
()
| 142 | // resyncChan returns a channel which will receive something when a resync is |
| 143 | // required, and a cleanup function. |
| 144 | func (r *Reflector) resyncChan() (<-chan time.Time, func() bool) { |
| 145 | if r.resyncPeriod == 0 { |
| 146 | return neverExitWatch, func() bool { return false } |
| 147 | } |
| 148 | // The cleanup function is required: imagine the scenario where watches |
| 149 | // always fail so we end up listing frequently. Then, if we don't |
| 150 | // manually stop the timer, we could end up with many timers active |
| 151 | // concurrently. |
| 152 | t := r.clock.NewTimer(r.resyncPeriod) |
| 153 | return t.C(), t.Stop |
| 154 | } |
| 155 | |
| 156 | // ListAndWatch first lists all items and get the resource version at the moment of call, |
| 157 | // and then use the resource version to watch. |
no outgoing calls