Skip to content

Implement actual circuit breaker behavior (not only heartbeat timeout) #51

Open
jonasew opened this issue Apr 3, 2026 · 0 comments
Open
Assignees

Comments

@jonasew
Copy link
Member

jonasew commented Apr 3, 2026

(We could also agree to remove circuit breaker as a part of our specification if time does not allow it)

Problem: Heartbeat exists, breaker state machine does not.
Target files (new + touched):

  • GameNetworkHandler.java
  • FirebaseAPI.java

Refactor:

  • Add a small breaker component with closed/open/half-open states.
  • Trip breaker after configurable consecutive failures/timeouts.
  • While open, block non-essential network writes and surface reconnecting state.
  • Use half-open probe to recover.

Acceptance criteria:

  • After repeated heartbeat/write failures, network requests are throttled/paused.
  • Recovery resumes automatically once probe succeeds.
@francinv francinv self-assigned this Apr 6, 2026
francinv pushed a commit that referenced this issue Apr 6, 2026
- Add CircuitBreaker class in new network package with three states:
  CLOSED (requests pass), OPEN (requests blocked), HALF_OPEN (one probe)
- Trips after 3 consecutive heartbeat failures, 10s cooldown before probe
- Integrate into GameNetworkHandler: gates saveMove and sendHeartbeat
- Connection UI reflects breaker state (Disconnected/Reconnecting/latency)
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants