package runtimeworker

import (
	"context"
	rand "math/rand/v2"
	"time"
)

func waitRetryJitter(ctx context.Context, maximum time.Duration) {
	if maximum <= 0 {
		return
	}
	delay := time.Duration(rand.Int64N(maximum.Nanoseconds() + 1))
	timer := time.NewTimer(delay)
	defer timer.Stop()
	select {
	case <-ctx.Done():
	case <-timer.C:
	}
}
