private async Task<long> ExecAsync(SequenceKey sequenceKey, int retryAttempt)
{
var result = await TryGetSequenceValue(sequenceKey);
if (!result.Result)
{
if (retryAttempt < MaxNumberOfAttempts)
{
retryAttempt++;
result.Value = await ExecAsync(sequenceKey, retryAttempt);
}
else
{
throw new MaxRetryAttemptReachedException(MaxNumberOfAttempts);
}
}
return result.Value;
}