Skip to content

Commit e4ff812

Browse files
committed
refactor: Create ThrottleDuration constant
1 parent a3bf780 commit e4ff812

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import (
1919
const (
2020
AnnotationTTL = "k8s-ttl-controller.twin.sh/ttl"
2121

22-
MaximumFailedExecutionBeforePanic = 10 // Maximum number of allowed failed executions before panicking
23-
ExecutionTimeout = 10 * time.Minute // Maximum time for each reconciliation before timing out
24-
ExecutionInterval = 5 * time.Minute // Interval between each reconciliation
22+
MaximumFailedExecutionBeforePanic = 10 // Maximum number of allowed failed executions before panicking
23+
ExecutionTimeout = 10 * time.Minute // Maximum time for each reconciliation before timing out
24+
ExecutionInterval = 5 * time.Minute // Interval between each reconciliation
25+
ThrottleDuration = 50 * time.Millisecond // Duration to sleep for throttling purposes
2526
)
2627

2728
var (
@@ -136,13 +137,13 @@ func DoReconcile(dynamicClient dynamic.Interface, resources []*metav1.APIResourc
136137
log.Printf("[%s/%s] deleted", apiResource.Name, item.GetName())
137138
}
138139
// Cool off a tiny bit to avoid hitting the API too often
139-
time.Sleep(50 * time.Millisecond)
140+
time.Sleep(ThrottleDuration)
140141
} else {
141142
log.Printf("[%s/%s] is configured with a TTL of %s, which means it will expire in %s", apiResource.Name, item.GetName(), ttl, time.Until(item.GetCreationTimestamp().Add(ttlInDuration)).Round(time.Second))
142143
}
143144
}
144145
// Cool off a tiny bit to avoid hitting the API too often
145-
time.Sleep(50 * time.Millisecond)
146+
time.Sleep(ThrottleDuration)
146147
}
147148
}
148149
return true

0 commit comments

Comments
 (0)