codexproxy

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func (b *LimitBook) LimitedUntil(uuid string, now time.Time) (time.Time, bool)

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

func (b *LimitBook) MarkLimited(uuid string, until time.Time)

MarkLimited records a deadline the endpoint stated.

func (*LimitBook) MarkLimitedFor

func (b *LimitBook) MarkLimitedFor(uuid string, until time.Time, resetKnown bool)

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.

func (*LimitBook) ResetsAt

func (b *LimitBook) ResetsAt(uuid string, now time.Time) (time.Time, bool)

ResetsAt is LimitedUntil restricted to deadlines the endpoint stated, and it is the only one an answer to codex may quote.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL