tickLoop runs on the calling goroutine. Wakes on notifyCh OR on the pollInterval timer (whichever first). Drains a batch each wake.
(ctx context.Context)
| 165 | // tickLoop runs on the calling goroutine. Wakes on notifyCh OR on the |
| 166 | // pollInterval timer (whichever first). Drains a batch each wake. |
| 167 | func (w *OutboxWorker) tickLoop(ctx context.Context) { |
| 168 | ticker := time.NewTicker(w.pollInterval) |
| 169 | defer ticker.Stop() |
| 170 | for { |
| 171 | select { |
| 172 | case <-ctx.Done(): |
| 173 | return |
| 174 | case <-w.notifyCh: |
| 175 | w.Tick(ctx) |
| 176 | case <-ticker.C: |
| 177 | w.Tick(ctx) |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // Tick processes one batch of pending events. Exposed (not just the |
| 183 | // private processBatch) so integration tests can drive the worker |