Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TimerWithCancel ¶
TimerWithCancel exists because we had several memory leaks when using time.After in select statements. Instead, we now manually create timers, wait on them, and manually free them. See this for more details: https://www.arangodb.com/2020/09/a-story-of-a-memory-leak-in-go-how-to-properly-use-time-after/
Warning: the cancel cannot be done concurrent to reading, everything should work in the same routine
Example:
for retries := 0; true; retries++ {
...main logic...
timer, cancel := ftime.TimerWithCancel(utils.Backoff(retries))
select {
case <-ctx.Done():
cancel()
return ctx.Err()
case <-timer.C:
continue
}
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.