(rollout: readonly RolloutBatch[], bucket: number)
| 32 | * fall into the slowest cohort, and oversized delays are clamped to 24h. |
| 33 | */ |
| 34 | export function rolloutDelayForBucket(rollout: readonly RolloutBatch[], bucket: number): number { |
| 35 | let cumulative = 0; |
| 36 | for (const batch of rollout) { |
| 37 | cumulative += batch.percent; |
| 38 | if (bucket < cumulative) { |
| 39 | return Math.min(Math.max(batch.delaySeconds, 0), MAX_ROLLOUT_DELAY_SECONDS); |
| 40 | } |
| 41 | } |
| 42 | if (rollout.length === 0) return 0; |
| 43 | return MAX_ROLLOUT_DELAY_SECONDS; |
| 44 | } |
| 45 | |
| 46 | export function rolloutDelaySeconds(manifest: UpdateManifest, deviceId: string): number { |
| 47 | return rolloutDelayForBucket(manifest.rollout, rolloutBucket(deviceId, manifest.version)); |
no outgoing calls
no test coverage detected