| 124 | } |
| 125 | |
| 126 | func nextInstancePollDelay(transitionAge time.Duration) time.Duration { |
| 127 | switch { |
| 128 | case transitionAge < 2*time.Minute: |
| 129 | return 1 * time.Second |
| 130 | case transitionAge < 10*time.Minute: |
| 131 | return 10 * time.Second |
| 132 | case transitionAge < time.Hour: |
| 133 | return 30 * time.Second |
| 134 | case transitionAge < 2*time.Hour: |
| 135 | return 60 * time.Second |
| 136 | default: |
| 137 | return 5 * time.Minute |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func nextEmptyPollDelay(emptyStartedAt time.Time) time.Duration { |
| 142 | if emptyStartedAt.IsZero() || time.Since(emptyStartedAt) < emptyPollBackoffAfter { |