()
| 138 | } |
| 139 | |
| 140 | func (q *Queue) flushIfNeeded() { |
| 141 | if q.pending >= q.batchSize { |
| 142 | q.l.Infow("executing flush", "items", q.pending) |
| 143 | var now = time.Now() |
| 144 | q.flushFunc(q.pendingItems) |
| 145 | q.pending = 0 |
| 146 | q.pendingItems = make([]*Item, q.batchSize) |
| 147 | q.l.Infow("flush complete", |
| 148 | "items", q.pending, |
| 149 | "duration", time.Since(now)) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | func (q *Queue) stop() { |
| 154 | q.smux.Lock() |