Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created January 13, 2020 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/a9cade2ea6d00681f6c2189aa2285e50 to your computer and use it in GitHub Desktop.
Save explorer14/a9cade2ea6d00681f6c2189aa2285e50 to your computer and use it in GitHub Desktop.
var policies = Policy
.Handle<MySqlException>(x => x.IsFailoverException())
.WaitAndRetry(5,
retry => TimeSpan.FromSeconds(retry * 5),
(a, b) =>
{
var mySqlEx = a as MySqlException;
Log.Logger.Warning(
"Failed with: {@error}. Retrying in {x} seconds...",
new
{
Msg = mySqlEx.Message,
Number = mySqlEx.Number,
HR = mySqlEx.HResult
},
b.TotalSeconds);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment