Skip to content

feat(cache): add per-breaker persistent stale ceiling#1664

Open
aashirpersonal wants to merge 1 commit intokoala73:mainfrom
aashirpersonal:feat/per-breaker-stale-ceiling
Open

feat(cache): add per-breaker persistent stale ceiling#1664
aashirpersonal wants to merge 1 commit intokoala73:mainfrom
aashirpersonal:feat/per-breaker-stale-ceiling

Conversation

@aashirpersonal
Copy link

Summary

Adds an optional persistentStaleCeilingMs parameter to CircuitBreakerOptions so individual breakers can override the global 24 h PERSISTENT_STALE_CEILING_MS constant.

Risk scores breaker now uses a 1 h ceiling — day-old CII data is unacceptable for a conflict monitoring app.

Closes #1326

Changes

src/utils/circuit-breaker.ts

  • Added persistentStaleCeilingMs? to CircuitBreakerOptions interface
  • Added private instance field + constructor assignment (falls back to global 24 h default)
  • Replaced global constant usage with instance field in hydratePersistentCache()

src/services/cached-risk-scores.ts

  • Risk scores breaker now passes persistentStaleCeilingMs: 60 * 60 * 1000 (1 h)

Backward compatible

All existing breakers continue using the 24 h default — only breakers that explicitly set persistentStaleCeilingMs are affected.

Add optional `persistentStaleCeilingMs` to `CircuitBreakerOptions`
so individual breakers can override the global 24 h
`PERSISTENT_STALE_CEILING_MS` constant.

Risk scores breaker now uses a 1 h ceiling since day-old CII data
is unacceptable for a conflict monitoring app.

Closes koala73#1326
@vercel
Copy link

vercel bot commented Mar 15, 2026

@aashirpersonal is attempting to deploy a commit to the Elie Team on Vercel.

A member of the Team first needs to authorize it.

@koala73
Copy link
Owner

koala73 commented Mar 15, 2026

You're right on the premise, @aashirpersonal all the magic numbers will be part of what differs between FREE and PRO users, I was paying a lot per day in hosting because I had very tight 1 to 5min refresh cycles.
I will review this PR and understand a bit more if I can manage to accept it with rules

@aashirpersonal
Copy link
Author

Thanks for the context @koala73! That makes sense — having per-breaker control is exactly what you'd need to differentiate refresh cycles between tiers.

This PR keeps it simple: just the optional override with the global 24h as default, so no existing behavior changes. Should slot in nicely as the foundation for tier-based config later. Happy to adjust anything if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cache): per-breaker persistent stale ceiling

2 participants