How to write retry policy in .net
I have the below code which is called by a webhook. It does a post call to a cms which has a rate limiting policy where it allows only 10 calls per second. So how to write a retry policy the api calls fails.
c#
public async Task HandleRedirectAsync(string slug, string previousSlug, string contentTypeId, string entryId)
{
var endpoint = "entries";
if (!string.IsNullOrEmpty(slug))
{
var isPreviousSlugNotEmpty = !String.IsNullOrEmpty(previousSlug);
var isSlugAndPreviousSlugSame = slug == previousSlug;
if (isPreviousSlugNotEmpty && isSlugAndPreviousSlugSame)
{
return;
}
await DeleteRedirectLoopsAsync(slug, contentTypeId, endpoint);
if (isPreviousSlugNotEmpty && !isSlugAndPreviousSlugSame)
{
await CreateAndPublishRedirectEntryAsync(entryId, previousSlug, slug);
}
await UpdateEntryAsync(contentTypeId, entryId);
}
}c#
public async Task HandleRedirectAsync(string slug, string previousSlug, string contentTypeId, string entryId)
{
var endpoint = "entries";
if (!string.IsNullOrEmpty(slug))
{
var isPreviousSlugNotEmpty = !String.IsNullOrEmpty(previousSlug);
var isSlugAndPreviousSlugSame = slug == previousSlug;
if (isPreviousSlugNotEmpty && isSlugAndPreviousSlugSame)
{
return;
}
await DeleteRedirectLoopsAsync(slug, contentTypeId, endpoint);
if (isPreviousSlugNotEmpty && !isSlugAndPreviousSlugSame)
{
await CreateAndPublishRedirectEntryAsync(entryId, previousSlug, slug);
}
await UpdateEntryAsync(contentTypeId, entryId);
}
}