Bird
0
0

Find the bug in this Circuit Breaker pseudocode:

medium📝 Analysis Q7 of 15
Microservices - Advanced Patterns
Find the bug in this Circuit Breaker pseudocode:
if failureCount > threshold:
  callService()
else:
  openCircuit()
AThe failureCount variable is not incremented
BThe logic is reversed; it should open circuit when failures exceed threshold
CThe callService() should be called only when circuit is open
DThe threshold comparison should use < instead of >
Step-by-Step Solution
Solution:
  1. Step 1: Understand correct Circuit Breaker logic

    Circuit opens when failureCount exceeds threshold to stop calls.
  2. Step 2: Analyze given code logic

    Code calls service when failures exceed threshold, which is reversed logic.
  3. Final Answer:

    The logic is reversed; it should open circuit when failures exceed threshold -> Option B
  4. Quick Check:

    Circuit Breaker logic reversal = The logic is reversed; it should open circuit when failures exceed threshold [OK]
Quick Trick: Open circuit when failures exceed threshold, not the opposite [OK]
Common Mistakes:
  • Reversing condition logic
  • Calling service when circuit should be open
  • Ignoring failure count updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes