* Advances the per-process round-robin cursor for a rotation pool and returns * the next index. Counters are per server instance, which keeps rotation free * of database writes; aggregate load still spreads evenly across keys.
(poolKey: string, poolSize: number)
| 26 | * of database writes; aggregate load still spreads evenly across keys. |
| 27 | */ |
| 28 | function nextRotationIndex(poolKey: string, poolSize: number): number { |
| 29 | const cursor = (rotationCounters.get(poolKey) ?? -1) + 1 |
| 30 | rotationCounters.set(poolKey, cursor) |
| 31 | return cursor % poolSize |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Resolves a workspace BYOK key for a provider. When the workspace has |
no test coverage detected