UNPKG

react-native-onyx

Version:

State management for React Native

25 lines (24 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CIRCUIT_BREAKER_TRANSITIONS = void 0; /** * Legal state transitions. The flow is closed → open → half-open → (closed | open). * * The **half-open** state exists so the breaker can test whether the dependency has recovered WITHOUT * flipping straight back to fully closed. Going open → closed blindly would, on a dependency that is * still down, immediately re-admit the full load and re-trip — flapping between open and closed every * window. Instead, after the open timeout the breaker moves to half-open and admits a single trial * ("probe") request: * - probe succeeds → the dependency is healthy again → transition to **closed** (resume normal flow). * - probe fails → still broken → transition back to **open** for another timeout window. * * Admitting exactly one probe (rather than reopening the floodgates) is also what prevents the * "thundering herd": many callers retrying at once the instant the timeout elapses, re-overwhelming a * dependency that was just starting to recover. */ const CIRCUIT_BREAKER_TRANSITIONS = { closed: ['open'], open: ['half-open'], 'half-open': ['closed', 'open'], }; exports.CIRCUIT_BREAKER_TRANSITIONS = CIRCUIT_BREAKER_TRANSITIONS;