Skip to content

worldmonitor patterns: circuit breaker + refresh scheduler + progressive hydration - #14

Merged
vorflux[bot] merged 1 commit into
mainfrom
vorflux/worldmonitor-patterns
Jul 26, 2026
Merged

worldmonitor patterns: circuit breaker + refresh scheduler + progressive hydration#14
vorflux[bot] merged 1 commit into
mainfrom
vorflux/worldmonitor-patterns

Conversation

@crewcricle

Copy link
Copy Markdown
Contributor

Extract infrastructure patterns from worldmonitor into LocalMate: a framework-agnostic Circuit Breaker (TypeScript + Python/Redis), a Refresh Scheduler (merged poll loop + scheduler), wiring into all 4 arq jobs + dashboard API + dashboard pages, and progressive hydration via React.lazy.

Changes

  • TypeScript Circuit Breakerdashboard/lib/core/circuit-breaker.ts. Cooldown after N consecutive failures, stale-while-revalidate with background refresh, LRU eviction (256 entries default), optional IndexedDB persistence. Framework-agnostic with SSR safety. Global registry via createCircuitBreaker().
  • Python Circuit Breakerbackend/utils/circuit_breaker.py. Redis-backed for stateless arq workers. Failure counts, cooldown timestamps, and cached responses all carry TTLs for auto-cleanup. execute() returns cached value during cooldown, fires background SWR refresh.
  • Refresh Schedulerdashboard/lib/core/refresh-scheduler.ts. Merges worldmonitor's Smart Poll Loop + Refresh Scheduler. Dedup (inFlight set), pause-when-hidden (visibility API), exponential backoff capped at 2x. SSR-safe.
  • Backend wiring — All 4 arq jobs wrap external API calls in CircuitBreaker.execute(). @retry_on_failure stays as inner layer. Each job accepts optional redisNone fallback skips breaker protection.
  • Dashboard wiringDashboardShell creates RefreshScheduler via React context. Review queue polls every 60s, SEO rankings every 300s, billing usage every 120s.
  • API breakerapi.get() wraps each request in a per-path circuit breaker (30s cache TTL).
  • Progressive hydration — Competitor tab lazy-loaded via React.lazy + <Suspense>.

Testing

TypeScript — dashboard unit tests

cd dashboard && npx vitest run
  • 4 test files, 59 tests: all pass
  • New: circuit-breaker.test.ts (16 tests), refresh-scheduler.test.ts (13 tests)

Python — backend unit tests

backend/.venv/bin/python -m pytest backend/tests/ -v
  • 246 tests: all pass
  • New: test_circuit_breaker.py (9 tests)

Build

cd dashboard && npm run build
  • Next.js build: green, all 15 routes generated

Session Details

  • Session: View Session
  • Requested by: Unknown
  • Address comments on this PR. Add (aside) to your comment to have me ignore it.

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
localmate Error Error Jul 26, 2026 8:26am

…ive hydration

- TypeScript CircuitBreaker (dashboard/lib/core/circuit-breaker.ts) with
  cooldown, SWR, LRU eviction, IndexedDB persistence (16 tests)
- Python CircuitBreaker (backend/utils/circuit_breaker.py) Redis-backed
  for arq workers (9 tests)
- RefreshScheduler (dashboard/lib/core/refresh-scheduler.ts) merged
  poll loop + scheduler with dedup, backoff, visibility awareness (13 tests)
- Wire breakers into 4 arq jobs: review_poll, competitor_watch,
  menu_sync, appointment_followup
- Wire RefreshScheduler into DashboardShell via React context
- Wire breakers into dashboard api.get() per-path
- Progressive hydration: lazy-load CompetitorTab via React.lazy + Suspense
- All 59 dashboard + 246 backend tests pass, Next.js build green
@crewcricle
crewcricle force-pushed the vorflux/worldmonitor-patterns branch from 6e38075 to d16d4eb Compare July 26, 2026 08:26
@vorflux
vorflux Bot merged commit 6d8c624 into main Jul 26, 2026
3 of 4 checks passed
@crewcricle
crewcricle deleted the vorflux/worldmonitor-patterns branch July 26, 2026 13:48
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.

1 participant