()
| 151 | } |
| 152 | |
| 153 | func (q *Queue) stop() { |
| 154 | q.smux.Lock() |
| 155 | |
| 156 | q.l.Infow("executing close", |
| 157 | "items", q.pending) |
| 158 | var now = time.Now() |
| 159 | if err := q.flushFunc(q.pendingItems); err != nil { |
| 160 | q.l.Errorw("unable to flush", "error", err) |
| 161 | } |
| 162 | if err := q.closeFunc(); err != nil { |
| 163 | q.l.Errorw("error occured on close", "error", err) |
| 164 | } |
| 165 | q.l.Infow("queue and index closed", |
| 166 | "duration", time.Since(now)) |
| 167 | |
| 168 | // prevent further entries |
| 169 | q.stopped = true |
| 170 | |
| 171 | q.smux.Unlock() |
| 172 | } |