various improvements
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-30 12:01:39 +10:00
parent 6f5d21fa71
commit ea63ffa178
11 changed files with 146 additions and 31 deletions

View File

@@ -1,11 +1,13 @@
package utils
import (
"context"
"log"
"log/slog"
"net"
"os"
"path/filepath"
"time"
)
const rsaBits = 4096
@@ -53,3 +55,14 @@ func FileExists(filename string) bool {
}
return !info.IsDir()
}
func SleepWithContext(ctx context.Context, d time.Duration) {
timer := time.NewTimer(d)
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
case <-timer.C:
}
}