Bird
Raised Fist0
HLDsystem_design~10 mins

Circuit breaker pattern in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the state when the circuit breaker allows requests.

HLD
state = "[1]"  # State when requests are allowed
Drag options to blanks, or click blank then click option'
AHalf-Open
BOpen
CClosed
DDisabled
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'Open' which actually blocks requests.
Confusing 'Half-Open' with the normal state.
2fill in blank
medium

Complete the code to specify the state when the circuit breaker blocks requests.

HLD
if failure_count > threshold:
    state = "[1]"  # Block requests
Drag options to blanks, or click blank then click option'
AOpen
BClosed
CHalf-Open
DDisabled
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'Closed' which allows requests.
Confusing 'Half-Open' with the blocking state.
3fill in blank
hard

Fix the error in the code to transition the circuit breaker to the state that tests if the system has recovered.

HLD
if timeout_expired:
    state = "[1]"  # Test system recovery
Drag options to blanks, or click blank then click option'
ADisabled
BClosed
COpen
DHalf-Open
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Open' which keeps blocking requests.
Using 'Closed' which allows all requests without testing.
4fill in blank
hard

Fill both blanks to complete the request handling logic in the circuit breaker.

HLD
if state == "[1]":
    allow_request = True
elif state == "[2]":
    allow_request = False
Drag options to blanks, or click blank then click option'
AClosed
BOpen
CHalf-Open
DDisabled
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the states and their meanings.
Using 'Disabled' which is not part of normal flow.
5fill in blank
hard

Fill all three blanks to complete the dictionary representing circuit breaker states and their descriptions.

HLD
states = {
    "Closed": "[1]",
    "Open": "[2]",
    "Half-Open": "[3]"
}
Drag options to blanks, or click blank then click option'
ARequests allowed
BRequests blocked
CTest limited requests
DSystem disabled
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing descriptions between states.
Including 'System disabled' which is not a standard state.