Polly: The fallback position

Parrot flying with Eagles

How many times in an application dependent on some external resource do you have to write a function or a maybe a whole module to deal with fallback cases? Perhaps the web service you call is down and you fallback to data cached from the last call, or a ftp site is not available so you send the third-party an automatic email to notify them. As developers we are constantly coding fallbacks.

Last week I gave a brief introduction to Polly a fault handling library built for .Net Standard and .Net Core. We looked at the wait and retry functionality that the library has, which would be useful if the external resource is having a blip, but what about if it is down, how do we gracefully degrade?

Continue reading →

Polly Introductions

Parrot flying with Eagles

Photo by Alexandre Debiève on Unsplash

Having seen mention of Polly on Scott Hanselmann’s blog and heard Dylan Reisenberger enthusiastically talk about it on  .Net Rocks, I was keen to have a look at this library and see what it can do.

Any type of integration relies on an IO operation that often out of control of the developer, we use web services that can go down, open and read files from remote servers that can be suddenly inaccessible, rely on database connections that can drop. Adding code to deal with this has always been essential to any integration module.

As an example I have created small console application that opens and reads an excel file, that is already open causing an IOException. I will add the Polly library to this and set up a policy to retry the operation while prompting the user to close the file.

Continue reading →