Skip to content

Commit

Permalink
Set RetryContext for the first execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
alrod committed Mar 26, 2021
1 parent 6799c9f commit 3f4ec78
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public static async Task<IDelayedException> TryExecuteAsync(this IFunctionExecut
logger = loggerFactory.CreateLogger(LogCategories.CreateFunctionCategory(functionInstance.FunctionDescriptor.LogName));
}

if (retryContext == null && functionInstance.FunctionDescriptor.RetryStrategy != null)
{
retryContext = new RetryContext();
retryContext.MaxRetryCount = functionInstance.FunctionDescriptor.RetryStrategy.MaxRetryCount;
}

if (retryContext != null && functionInstance is FunctionInstance instance)
{
retryContext.Instance = instance;
Expand All @@ -57,9 +63,7 @@ public static async Task<IDelayedException> TryExecuteAsync(this IFunctionExecut
break;
}

retryContext = retryContext ?? new RetryContext();
retryContext.RetryCount = attempt;
retryContext.MaxRetryCount = functionInstance.FunctionDescriptor.RetryStrategy.MaxRetryCount;
retryContext.Exception = functionResult?.Exception;

TimeSpan nextDelay = retryStrategy.GetNextDelay(retryContext);
Expand Down

0 comments on commit 3f4ec78

Please sign in to comment.