Created
March 3, 2015 08:02
-
-
Save HowardvanRooijen/eaf4a1068cd5734b1976 to your computer and use it in GitHub Desktop.
StorageWriteExceptionRetryPolicy extension for Endjin.Retry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Using Directives | |
using System; | |
using System.Diagnostics; | |
using System.Net; | |
using Endjin.Core.Retry.Policies; | |
using Endjin.Kpi.Core.Extensions; | |
using Microsoft.WindowsAzure.Storage; | |
#endregion | |
public class StorageWriteExceptionRetryPolicy : IRetryPolicy | |
{ | |
public bool CanRetry(Exception ex) | |
{ | |
Trace.TraceError(ex.GetFullExceptionMessage()); | |
var we = ex as WebException; | |
if (we != null && we.Status == WebExceptionStatus.ProtocolError) | |
{ | |
return false; | |
} | |
var se = ex as StorageException; | |
if (se != null && se.RequestInformation.HttpStatusCode == (int)HttpStatusCode.Conflict) | |
{ | |
return false; | |
} | |
return ex is LeaseException; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment