19 lines
246 B
Go
19 lines
246 B
Go
package collector
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
func sleepWithContext(ctx context.Context, d time.Duration) bool {
|
|
timer := time.NewTimer(d)
|
|
defer timer.Stop()
|
|
|
|
select {
|
|
case <-ctx.Done():
|
|
return false
|
|
case <-timer.C:
|
|
return true
|
|
}
|
|
}
|