Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

321 B
Raw Blame
package sample

import (
	"context"
	"time"
)

// SleepContext waits for duration or returns the context error.
func SleepContext(ctx context.Context, duration time.Duration) error {
	timer := time.NewTimer(duration)
	defer timer.Stop()
	select {
	case <-ctx.Done():
		return ctx.Err()
	case <-timer.C:
		return nil
	}
}