Bird
0
0

What is wrong with this circuit breaker failure count update?

medium📝 Analysis Q7 of 15
Microservices - Resilience Patterns
What is wrong with this circuit breaker failure count update?
try:
  call_service()
except:
  breaker.failureCount = 1
AIt resets failureCount to 1 instead of incrementing
BIt increments failureCount correctly
CIt does not change failureCount at all
DIt sets failureCount to zero on failure
Step-by-Step Solution
Solution:
  1. Step 1: Understand failure count update logic

    Failure count should increase by 1 on each failure, not reset to 1.
  2. Step 2: Identify the bug in assignment

    Code sets failureCount to 1 every failure, losing previous count.
  3. Final Answer:

    It resets failureCount to 1 instead of incrementing -> Option A
  4. Quick Check:

    Failure count must increment, not reset [OK]
Quick Trick: Increment failureCount, don't reset it on failure [OK]
Common Mistakes:
MISTAKES
  • Resetting failureCount instead of incrementing
  • Ignoring failureCount updates
  • Confusing failureCount with state

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes