Documentation
¶
Overview ¶
Package codexproxy is ccdad's loopback reverse proxy for codex.
This file is the one piece of it the daemon's Codex lane needs before the proxy itself exists: the rate-limit record the two share.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LimitBook ¶
type LimitBook struct {
// contains filtered or unexported fields
}
LimitBook is what ccdad knows about which Codex accounts are currently throttled, shared by the daemon's Codex lane and the proxy handler.
It is in-memory and deliberately not persisted. A 429 from chatgpt.com is a fact about a window that is measured in minutes to hours, and a daemon that restarts has to re-learn it from the endpoint anyway -- whereas a persisted record would outlive the throttle it describes and hold an account out on evidence nobody could re-check.
The zero value is usable, and so is a nil pointer: a nil book answers "no limit" to everything, which is what an attended `ccdad switch` -- a process with no proxy in it -- has to be able to hand in.
func (*LimitBook) LimitedUntil ¶
LimitedUntil is when an account's throttle lifts, and whether one is in force at all right now.
A record whose instant has passed answers no rather than being swept: there is no sweeper, and expiring on read is what keeps a book that nobody prunes from holding an account out forever on one 429.
func (*LimitBook) MarkLimited ¶
MarkLimited records a deadline the endpoint stated.
func (*LimitBook) MarkLimitedFor ¶
MarkLimitedFor records a deadline and whether the endpoint stated it.
The LATER instant always wins. Two writers reach this -- the lane's poll, which learns a limit from /wham/usage, and the proxy, which learns one from a 429 on a real turn -- and the two see different Retry-After values for the same window. Taking the shorter one would send the next request straight back into the throttle.
A nil book records nothing, which is the whole of what a process with no proxy in it needs from this type.