mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Adds a use-it-or-lose-it scheduling strategy: prefer accounts whose session window resets soonest, so near-reset accounts get drained first instead of accounts whose reset is still far away. Both schedulers, opt-in, default behavior unchanged: - Anthropic (gateway_service.go): new GatewaySchedulingConfig .PreferSoonestReset flag. When on, the layered load-aware selection inserts a filterBySoonestReset stage (priority -> soonest-reset -> load -> LRU). Accounts with no active SessionWindowEnd are treated as lowest priority; ties fall through to LRU. - OpenAI/Codex (openai_account_scheduler.go): new "reset" score weight in GatewayOpenAIWSSchedulerScoreWeights. Soonest-reset accounts score higher; weight defaults to 0 (no effect). SessionWindowEnd (upstream 5h/quota ResetsAt) is already carried in the scheduler snapshot, so no snapshot changes are needed. Documented in deploy/config.example.yaml. Adds unit tests for the Anthropic filter and the OpenAI reset factor.