Merge C24 federation: another llmgw cluster as a provider

Conflicts with facility-aware placement (config, control, admin API routes,
store test tables) all keep both; the generated reference and OpenAPI
document regenerated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 01:29:35 +02:00
commit 33334c8f33
33 files changed
+2945 -24

No files matched your search

+14 -1
View File
@@ -149,6 +149,10 @@ type Request struct {
Body []byte
// Header carries headers to forward (authorization is deliberately not).
Header http.Header
// Extra are headers set on the upstream request beyond those forwarded
// from the client: what the router itself says to this upstream, such
// as the hop header a federated cluster is sent.
Extra http.Header
// APIKey is the engine's own key, sent in place of the client's.
APIKey string
// Stream says whether an SSE response is expected.
@@ -255,6 +259,9 @@ func (p *Proxy) Do(ctx context.Context, w http.ResponseWriter, r Request) (Outco
return Outcome{Retryable: false}, err
}
req.Header = cloneForUpstream(r.Header)
for k, vs := range r.Extra {
req.Header[http.CanonicalHeaderKey(k)] = vs
}
ct := r.ContentType
if ct == "" {
ct = "application/json"
@@ -625,9 +632,15 @@ var hopByHop = map[string]bool{
"Upgrade": true,
}
// copyHeaders gives the client the upstream's response headers.
//
// A header the gateway has already set is its own answer and is kept: an
// upstream that is itself an llmgw — a federated peer — sends X-Request-Id
// and x-llmgw-served-model of its own, and the client would otherwise be
// given both.
func copyHeaders(dst, src http.Header) {
for k, vs := range src {
if hopByHop[http.CanonicalHeaderKey(k)] {
if hopByHop[http.CanonicalHeaderKey(k)] || len(dst.Values(k)) > 0 {
continue
}
for _, v := range vs {