Implementing the retry pattern in c sharp using Polly

This post is the third and final installment on the retry pattern following on from implementing a simple retry pattern in c# and the retry pattern for async tasks. In the last two posts we created a retry helper class to allow us to add retry logic to applications without cluttering important application logic with retry code. Now we will solve the same problem using a popular OSS library. Polly is an open source framework for that “allows developers to express transient exception and fault handling policies such as Retry, Retry Forever, Wait and Retry, or Circuit Breaker in a fluent manner”....

December 29, 2016 · 3 min · 611 words

Implementing the retry pattern for async tasks in c#

This post is a follow on from Implementing a simple retry pattern in c#. Tasks, async and await are rapidly becoming be default API flavours in many dotnet libraries and the performance benefits for IO bound code have been well documented. However if you need to apply the retry pattern to some async or task returning method invocation you need to watch out for subtle errors. I’ll outline the problem and revise my solution from the previous post....

December 2, 2016 · 3 min · 470 words

Implementing a simple retry pattern in c#

Everything is unstable. You cannot assume that every external service call will succeed on first attempt - the load balancer might be removing a failing host, the database might be being patched, the Ops person might have tripped on the network cable and quickly plugged it back in hoping the boss didn’t notice. If you make an outbound call you probably need an easy way to retry a couple of times before giving up and raising an exception....

December 1, 2016 · 3 min · 629 words

Converting an SVN repository to Git on windows

Git is everywhere these days, and I can’t really remember how I used to cope without the power of local distributed source control and quick branching. But once in a while I find an old SVN repository I need to convert to git and then push to a git server like github. Here are the easy steps to switch a repositiry from SVN to git and keep the full history. Much is based on the excellent Pro Git book http://git-scm....

November 17, 2016 · 4 min · 779 words

Cache the result of an async method using LazyCache

The latests release of LazyCache, my open source cache library based on ObjectCache, makes it easy to cache the results of asynchronous or Task returning methods, so now it is simpler for you to speed up your application. Why bother with Async? Async code tends to be more efficient as you release threads while they are waiting for the response from an asynchronous resource, but at a cost of added code complexity....

September 30, 2016 · 3 min · 626 words

I have to rebase and squash before the pull request will be accepted?!

TL/DR If you want your pull requests to be taken seriously you probably need to learn some more advanced git features like interactive rebase and squash. Fist I wanted to share an article I found when helping folks that struggle with code review/pull request comments like “Can you rebase that” or “I don’t want to see all your workings – please squash your commits”. If that applies to you, I suggest you have a read of Git Interactive Rebase, Squash, Amend and Other Ways of Rewriting History....

September 8, 2016 · 2 min · 380 words

How to run a dotnet windows service as a console app

C# Windows services can be a pain to develop because they are awkward to test, debug and run locally. However a few tweaks to the default VS template make them far more manageable. Why use a windows service in the first place? At first glance a Windows Service looks like old tech in an age of http everywhere. However they are a reliable proven platform that is easy to deploy, easy to remotely monitor, and it is actually trivial to embed a web-server inside one and ditch IIS entirely....

August 29, 2016 · 3 min · 618 words

Detecting plurals in dot.net / C# the way a human might

I recently had a requirement to be able to spot pluralised words which may not be real words, but follow English language conventions, and so appear as a plural to any normal reader. So ComplexBusinesObjects is a valid plural of ComplexBusinesObject but series is its own plural. The idea was to write code that would recognise a plural in the same way a human might, even if it was not perfect grammar....

August 16, 2016 · 2 min · 361 words

Fixing intermittant 'EPERM: operation not permitted' on npm install

The npm install step in my Teamcity CI build for an angular app I have been working has been failing intermittently and I finally uncovered the reason. TL/DR The combination of McAfee Anti-virus and network mounted user AppData folders was the culprit - moving them to an unscanned local folder fixed it. npm install was failing the build intermittently when run by our build software Teamcity on a windows agent with ugly errors like:...

July 4, 2016 · 2 min · 410 words

An agile project retrospective - tips for your (and my) next project

Insanity: doing the same thing over and over again and expecting different results. Albert Einstein I recently finished another agile development project and we ran some really great retrospectives over the 9 months, along with a thorough review at the end. We captured lots of data and feedback and I decided to pick out the best and publish them in the hope of not making the same mistakes in future....

June 7, 2016 · 5 min · 1015 words