﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Lying as a valid coding pattern</title><description>Mike,
  
_Nice_ catch
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment12</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment12</guid><pubDate>Thu, 23 Jul 2009 09:03:20 GMT</pubDate></item><item><title>Mike Scott commented on Lying as a valid coding pattern</title><description>There's also an insidious bug in your code, which I thought I'd point out because many programmers make the same mistake: by using DateTime.Now, the code can malfunction in the fall when the clock goes back and the circuit breaker will get stuck in the closed state for an hour longer than it should. It's perhaps not a big issue in this case, but one which can cause inexplicable behaviour.
  
  
Solution: always use DateTime.UtcNow for this.
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment11</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment11</guid><pubDate>Thu, 16 Jul 2009 10:04:14 GMT</pubDate></item><item><title>Will commented on Lying as a valid coding pattern</title><description>I can see how the apparent difference in behavior would not occur because of how the class is used in the context of a circuit breaker.
  
  
My guess is that the MoveToHalfOpenState doesn't need to happen unless someone is attempting a protected action.
  
  
Also, after moving to the HalfOpenState, the ProtectedCode... of the OpenState class would no longer be called.
  
  
Just my guess after thinking about it more.
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment10</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment10</guid><pubDate>Wed, 15 Jul 2009 17:29:39 GMT</pubDate></item><item><title>Chad Lee commented on Lying as a valid coding pattern</title><description>Your code does not work the same.  In your implementation, after the protected service was working again and the timeout was up, it would take two calls to the service to get the circuit breaker to actually call the service again.
  
  
In the original implementation, the circuit breaker would correctly start calling the service again on the first call once the timeout was up.
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment9</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment9</guid><pubDate>Wed, 15 Jul 2009 17:29:24 GMT</pubDate></item><item><title>Dylan commented on Lying as a valid coding pattern</title><description>Also in the first example the MoveToHalfOpenState is called automatically a certain time after the ctor executes.  In the 2nd example MoveToHalfOpenState is only called if the caller explicitly calls ProtectedCodeIsAboutToBeCalled after the timeout.
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment8</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment8</guid><pubDate>Wed, 15 Jul 2009 16:44:42 GMT</pubDate></item><item><title>Will commented on Lying as a valid coding pattern</title><description>My mistake, the second only if not expired
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment7</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment7</guid><pubDate>Wed, 15 Jul 2009 15:53:02 GMT</pubDate></item><item><title>Will commented on Lying as a valid coding pattern</title><description>I don't know what a circuit breaker is, but at a glance it would appear the two versions of the code would behave quite differently.
  
  
In the first, the ProtectedCodeIsAboutToBeCalled method will through an exception regardless of any "timeout".
  
  
In the second, the exception only occurs if the time has expired.
  
  
Am I missing something?
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment6</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment6</guid><pubDate>Wed, 15 Jul 2009 15:51:15 GMT</pubDate></item><item><title>Victor Kornov commented on Lying as a valid coding pattern</title><description>Timer or a similar approach is valid, when you do not want to force unwanted side effects of testing if external system is up on your currently executing thread, i.e. UI. If the system is down and timeouts you don't want to wait for like 30 seconds with your UI freezed or web server thread doing nothing but waiting. Going timer + background thread solves this problem by "pinging" external system in the background.
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment5</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment5</guid><pubDate>Wed, 15 Jul 2009 13:22:31 GMT</pubDate></item><item><title>Davy Brion commented on Lying as a valid coding pattern</title><description>@Ollie Riches
  
  
it's not a retry-policy at all... the code never retries an operation.  If a protected resource is known to have failed X amount of times, it simply fails immediately (which opens the circuit) instead of actually calling the protected resource. 
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment4</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment4</guid><pubDate>Wed, 15 Jul 2009 13:02:20 GMT</pubDate></item><item><title>Ollie Riches commented on Lying as a valid coding pattern</title><description>To me this pattern really isn't a 'circuit breaker' in the true sense of the word it's more of a 'retry policy' - I guess 'circuit breaker' sounds better though ;)
  
  
But like a circuit breaker it doesn't tell why the problem occurred just that it has...
  
  
  
  
  
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment3</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment3</guid><pubDate>Wed, 15 Jul 2009 11:18:00 GMT</pubDate></item><item><title>Ed Blackburn commented on Lying as a valid coding pattern</title><description>It's been over two years since Michael Nygard's excellent Release It! book was published. It's good to see some detailed debate and implementations of this pattern in C#.
  
  
[ayende.com/.../...g-as-a-valid-coding-pattern.aspx](http://ayende.com/Blog/archive/2009/07/15/lying-as-a-valid-coding-pattern.aspx)  
  
[davybrion.com/.../protecting-your-application-f...](http://davybrion.com/blog/2009/07/protecting-your-application-from-remote-problems/)  
  
[timross.wordpress.com/.../implementing-the-circ...](http://timross.wordpress.com/2008/02/17/implementing-the-circuit-breaker-pattern-in-c-part-2/)  
  
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment2</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment2</guid><pubDate>Wed, 15 Jul 2009 09:54:45 GMT</pubDate></item><item><title>alex commented on Lying as a valid coding pattern</title><description>I guess we should also separate the decision making mechanism from the actual breaker. I mean you caught the exception - how are supposed to know that is caused by the remote service overload?
</description><link>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment1</link><guid>http://ayende.com/4069/lying-as-a-valid-coding-pattern#comment1</guid><pubDate>Wed, 15 Jul 2009 08:56:03 GMT</pubDate></item></channel></rss>