code wiki / (root) / nx_circuit_breaker.nx

nx_circuit_breaker.nx

buildroot/runtime/nx_circuit_breaker.nx

9045 B230 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_circuit_breaker.nx -- 3-state circuit breaker (Hystrix pattern). module: nishi-core.ingest.circuit_breaker depends: nishi-core.io.syscalls, nishi-core.io.iso8601 disk_kb: 4 capability: CORE_IO license_tier: PUBLIC_NISHI_SUBSTRATE genealogy_id: nygard_2007_release_it_stability_patterns + netflix_hystrix_circuit_breaker_pattern + resilience4j_circuit_breaker_states + nishi_cardinal_14_graceful_degradation Three-state circuit breaker primitive. Substrate Cardinal 14 (graceful degradation) guard against runaway-failing upstreams: when an upstream returns errors at high frequency, the breaker trips OPEN and short-circuits subsequent calls without hitting the upstream. After a cool-down window, the breaker transitions to HALF_OPEN to test recovery; success closes it, failure re-trips. Per Pillar 5 equipment-health-verdict pattern applied at the ingestion-substrate layer: every adapter gets a breaker automatically; the substrate's poll-loop honors the verdict. ===== Why three states =========================================== CLOSED requests flow through; failures counted toward threshold OPEN requests short-circuited; counter timer running HALF_OPEN probe requests allowed; success → CLOSED, failure → OPEN

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_iso8601.nx nx_circuit_breaker.nx

imports: nx_syscalls.nxnx_iso8601.nx

imported by: nobody (leaf or entry point)

structs

68struct CircuitBreaker

consts

42const NX_BREAKER_CLOSED: i64 = 1
43const NX_BREAKER_OPEN: i64 = 2
44const NX_BREAKER_HALF_OPEN: i64 = 3
55const NX_BREAKER_VERDICT_PROCEED: i64 = 1
56const NX_BREAKER_VERDICT_SHORT_CIRCUIT: i64 = 2 // OPEN — don't call upstream
57const NX_BREAKER_VERDICT_PROBE: i64 = 3 // HALF_OPEN — single probe call
89const NX_CIRCUIT_BREAKER_BYTES: i64 = 120 // 15 fields * 8 bytes
93const NX_BREAKER_DEFAULT_FAILURE_PCT_Q10: i64 = 512 // 50% in Q10
94const NX_BREAKER_DEFAULT_MIN_REQUESTS: i64 = 10
95const NX_BREAKER_DEFAULT_COOLDOWN_SEC: i64 = 60
96const NX_BREAKER_DEFAULT_HALF_OPEN_PROBES: i64 = 3
152const NX_BREAKER_OUTCOME_SUCCESS: i64 = 1
153const NX_BREAKER_OUTCOME_FAILURE: i64 = 2

functions

46func nx_breaker_state_name(s: i64) -> *u8
59func nx_breaker_verdict_name(v: i64) -> *u8
100func nx_circuit_breaker_new(descriptor_hk: i64, now_unix: i64) -> *CircuitBreaker
calls 1: sys_mmap
126func nx_circuit_breaker_verdict(b: *CircuitBreaker, now_unix: i64) -> i64
155func nx_circuit_breaker_record_outcome(b: *CircuitBreaker, outcome: i64, now_unix: i64) -> i64
209func nx_circuit_breaker_force_trip(b: *CircuitBreaker, now_unix: i64) -> i64
220func nx_circuit_breaker_force_reset(b: *CircuitBreaker, now_unix: i64) -> i64