Single-binary self-hosted market watcher for stocks, ETFs, indexes, and futures: live charts, key stats, fundamentals, SEC filings, and SSE streaming.
axumdockerfinancerustself-hostedsqlitestocksvite
1-- finance migration 0002: per-endpoint request-guard state (Phase 3).
2--
3-- One row per outbound data endpoint (today only 'stooq'). It is the persistent
4-- backing store for `EndpointGuard` (src/guard.rs): a reactive circuit breaker
5-- plus a hard per-hour request budget, so a third-party rate limit can never be
6-- hit even across restarts or by a future job. All *_at columns are UTC
7-- epoch-milliseconds, matching the rest of the schema.
8
9CREATE TABLE endpoint_guard (
10 endpoint TEXT PRIMARY KEY, -- logical upstream id, e.g. 'stooq'
11
12 -- ── circuit breaker ──
13 state TEXT NOT NULL DEFAULT 'closed', -- closed | open | half_open
14 fail_streak INTEGER NOT NULL DEFAULT 0, -- consecutive ordinary failures while closed
15 trip_count INTEGER NOT NULL DEFAULT 0, -- consecutive trips; drives the backoff length
16 opened_at INTEGER, -- when the breaker last opened
17 retry_at INTEGER, -- earliest time a half-open probe may run
18
19 -- ── hard per-hour request budget ──
20 hour_start INTEGER, -- start of the current rolling budget hour
21 hour_count INTEGER NOT NULL DEFAULT 0, -- requests let through in the current hour
22
23 -- ── bookkeeping ──
24 last_request_at INTEGER, -- last request let through (drives pacing)
25 last_ok_at INTEGER,
26 last_error TEXT,
27 last_error_at INTEGER,
28 updated_at INTEGER NOT NULL
29);