(auths []*Auth, model string, now time.Time)
| 197 | } |
| 198 | |
| 199 | func collectAvailableByPriority(auths []*Auth, model string, now time.Time) (available map[int][]*Auth, cooldownCount int, earliest time.Time) { |
| 200 | available = make(map[int][]*Auth) |
| 201 | for i := 0; i < len(auths); i++ { |
| 202 | candidate := auths[i] |
| 203 | blocked, reason, next := isAuthBlockedForModel(candidate, model, now) |
| 204 | if !blocked { |
| 205 | priority := authPriority(candidate) |
| 206 | available[priority] = append(available[priority], candidate) |
| 207 | continue |
| 208 | } |
| 209 | if reason == blockReasonCooldown { |
| 210 | cooldownCount++ |
| 211 | if !next.IsZero() && (earliest.IsZero() || next.Before(earliest)) { |
| 212 | earliest = next |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | return available, cooldownCount, earliest |
| 217 | } |
| 218 | |
| 219 | func getAvailableAuths(auths []*Auth, provider, model string, now time.Time) ([]*Auth, error) { |
| 220 | if len(auths) == 0 { |
no test coverage detected