Skip to content

Commit ca03c81

Browse files
committed
better documentation around the circuit breaker
1 parent dbe7f0b commit ca03c81

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

docs/technical-design.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,47 @@ The following diagram illustrates the sequence of events when all RPC providers
1010

1111
```mermaid
1212
sequenceDiagram
13-
participant main as Main Oracle
14-
participant client as BlockchainClient
15-
participant circuit_breaker as CircuitBreaker
16-
participant slack as SlackNotifier
13+
# Setup column titles
14+
participant main_oracle as service_quality_oracle.py
15+
participant blockchain_client as blockchain_client.py
16+
participant circuit_breaker as circuit_breaker.py
17+
participant slack_notifier as slack_notifier.py
1718
18-
main->>client: batch_allow_indexers_issuance_eligibility()
19-
activate client
19+
# Attempt function call
20+
main_oracle->>blockchain_client: batch_allow_indexers_issuance_eligibility()
2021
22+
# Describe failure loop inside the blockchain_client module
23+
activate blockchain_client
2124
alt RPC Loop (for each provider)
22-
client->>client: _execute_rpc_call() with provider A
23-
note right of client: Fails after 5 retries
24-
client-->>client: raises ConnectionError
2525
26-
note right of client: Catches error, logs rotation
27-
28-
client->>client: _execute_rpc_call() with provider B
29-
note right of client: Fails after 5 retries
30-
client-->>client: raises ConnectionError
26+
# Attempt RPC call
27+
blockchain_client->>blockchain_client: _execute_rpc_call() with provider A
28+
note right of blockchain_client: Fails after 5 retries
3129
32-
note right of client: All providers tried and failed
30+
# Log failure
31+
blockchain_client-->>blockchain_client: raises ConnectionError
32+
note right of blockchain_client: Catches error, logs rotation
33+
34+
# Retry RPC call
35+
blockchain_client->>blockchain_client: _execute_rpc_call() with provider B
36+
note right of blockchain_client: Fails after 5 retries
37+
38+
# Log final failure
39+
blockchain_client-->>blockchain_client: raises ConnectionError
40+
note right of blockchain_client: All providers tried and failed
3341
end
34-
35-
client-->>main: raises Final ConnectionError
36-
deactivate client
37-
38-
main->>circuit_breaker: record_failure()
39-
main->>slack: send_failure_notification()
40-
note right of main: sys.exit(1) causes Docker restart
41-
```
42+
43+
# Raise error back to main_oracle oracle and exit blockchain_client module
44+
blockchain_client-->>main_oracle: raises Final ConnectionError
45+
deactivate blockchain_client
46+
47+
# Take note of the failure in the circuit breaker, which can break the restart loop if triggered enough times in a short duration
48+
main_oracle->>circuit_breaker: record_failure()
49+
50+
# Notify of the RPC failure in slack
51+
main_oracle->>slack_notifier: send_failure_notification()
52+
53+
# Document restart process
54+
note right of main_oracle: sys.exit(1)
55+
note right of main_oracle: Docker will restart. CircuitBreaker can halt via sys.exit(0)
56+
```

0 commit comments

Comments
 (0)