(now time.Time)
| 91 | } |
| 92 | |
| 93 | func (l *authAutoRefreshLoop) rebuild(now time.Time) { |
| 94 | type entry struct { |
| 95 | id string |
| 96 | next time.Time |
| 97 | } |
| 98 | |
| 99 | entries := make([]entry, 0) |
| 100 | |
| 101 | l.manager.mu.RLock() |
| 102 | for id, auth := range l.manager.auths { |
| 103 | next, ok := nextRefreshCheckAt(now, auth, l.interval) |
| 104 | if !ok { |
| 105 | continue |
| 106 | } |
| 107 | entries = append(entries, entry{id: id, next: next}) |
| 108 | } |
| 109 | l.manager.mu.RUnlock() |
| 110 | |
| 111 | l.mu.Lock() |
| 112 | l.queue = l.queue[:0] |
| 113 | l.index = make(map[string]*refreshHeapItem, len(entries)) |
| 114 | for _, e := range entries { |
| 115 | item := &refreshHeapItem{id: e.id, next: e.next} |
| 116 | heap.Push(&l.queue, item) |
| 117 | l.index[e.id] = item |
| 118 | } |
| 119 | l.mu.Unlock() |
| 120 | } |
| 121 | |
| 122 | func (l *authAutoRefreshLoop) loop(ctx context.Context) { |
| 123 | timer := time.NewTimer(time.Hour) |
nothing calls this directly
no test coverage detected