/// <inheritdoc />
        public async Task <Bucket> GetBucketAndWaitForAvailability(Request request, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            await timerFactory.CreateJitter(cancellationToken);

            var bucket = await repository.FindByEndpointAndMajorParameters(request.Endpoint, request.Parameters, cancellationToken);

            bucket ??= await CreateBucket(request, cancellationToken);

            if (bucket.HitsRemaining <= 1)
            {
                var delay = (int)Math.Ceiling((bucket.ResetAfter - DateTimeOffset.Now).TotalMilliseconds);
                delay = Math.Max(delay, 100);
                await timerFactory.CreateDelay(delay, cancellationToken);

                bucket.HitsRemaining++;
            }

            bucket.HitsRemaining--;
            return(bucket);
        }