mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3466] [Other] tools: the busbar gateway, one OpenAI address in front of several providers #4643
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4643
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3466
Author: @Buddychek
Created: 10/20/2026
Status: 🔄 Open
Base:
main← Head:tools/busbar-gateway📝 Commits (3)
8d28de6tools: busbar gateway - OpenAI-compatible router with weighted pools, failover, and cooldownc109e62tools: busbar gateway survives an upstream that drops the connection4794d97tools: the busbar test stand-ins close gracefully📊 Changes
4 files changed (+1239 additions, -0 deletions)
View changed files
➕
docs/BUSBAR.md(+115 -0)➕
tools/busbar.example.json(+53 -0)➕
tools/busbar_gateway.py(+475 -0)➕
tools/test_busbar_gateway.py(+596 -0)📄 Description
Problem and result. A client that has both a local Strata server and a hosted model has no single address for the two.
tools/busbar_gateway.pyputs one OpenAI-compatible/v1address in front of several providers: a name likefastis a pool of members with weights, 80/100 requests to Claude and 20/100 to GPT, spread evenly by smooth weighted round robin. A member that fails is tried on the next member of the pool, then on the pools listed infailover, and is put on cooldown aftermax_failsfailures in a row. Anthropic answers are converted to the OpenAI shape, SSE streams pass through, and/v1/models,/v1/statsand/v1/healthreport the pools. Nothing in the default path changes: the gateway is opt-in, stdlib only, and needs no engine, GPU or model.Related discussion: #3464 (scope not yet agreed by a maintainer - hence the draft).
Approach. The split has to be exact, so the router uses the same smooth weighted round robin nginx uses instead of a random draw;
--planshows the next N routes without sending anything, so a user can check a config before pointing a client at it. The last commit in this branch is the hardening a live PC forced: urllib hands a socket aborted before a status line as a rawConnectionAbortedError(WinError 10053), which the first version did not catch, so an upstream that dropped the connection killed the request with a traceback instead of failing over. Now every call path catchesOSErrorandhttp.clienterrors, a stream the provider cuts short is counted as a failure, and a client that stops reading is not blamed on the member.Validation (Windows 11, Python 3.14.7, commit
c109e625, no GPU, no provider key, no network):python -m unittest tools.test_busbar_gateway- 34 tests,OK, 15 runs in a row.ConnectionAbortedError [WinError 10053]; after it, 0 of 15. The cause was measured, not guessed: a stand-in upstream that returns headers and a body and then closes without flushing aborts the connection about once in 60 attempts on this PC (60-run A/B: 59 OK without the flush, 60 OK with it).python tools/busbar_gateway.py --config tools/busbar.example.json --plan --requests 20-counts: claude=16, gpt=4, the exact 80/20 spread.--plan --pool nopeprints the known pools and exits 2./v1/chat/completionswithstream: trueand reads the SSE back).Limits. One process, no request body size limit, one attempt per member per request, and the round-robin state is per pool, so two pools asking for the same member do not share a counter. No tests were run against Anthropic, OpenAI or Bedrock.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.