| 195 | } |
| 196 | |
| 197 | func (w *Watcher) dispatchAuthUpdates(updates []AuthUpdate) { |
| 198 | if len(updates) == 0 { |
| 199 | return |
| 200 | } |
| 201 | queue := w.getAuthQueue() |
| 202 | if queue == nil { |
| 203 | return |
| 204 | } |
| 205 | baseTS := time.Now().UnixNano() |
| 206 | w.dispatchMu.Lock() |
| 207 | if w.pendingUpdates == nil { |
| 208 | w.pendingUpdates = make(map[string]AuthUpdate) |
| 209 | } |
| 210 | for idx, update := range updates { |
| 211 | key := w.authUpdateKey(update, baseTS+int64(idx)) |
| 212 | if _, exists := w.pendingUpdates[key]; !exists { |
| 213 | w.pendingOrder = append(w.pendingOrder, key) |
| 214 | } |
| 215 | w.pendingUpdates[key] = update |
| 216 | } |
| 217 | if w.dispatchCond != nil { |
| 218 | w.dispatchCond.Signal() |
| 219 | } |
| 220 | w.dispatchMu.Unlock() |
| 221 | } |
| 222 | |
| 223 | func (w *Watcher) authUpdateKey(update AuthUpdate, ts int64) string { |
| 224 | if update.ID != "" { |