Issue #44: code-register memory adapter with standing-context resource; fix dispatcher method-level Auth.Capability override (was always using verb-derived capability, ignoring per-method Auth field). Issue #45: per-backend bounded in-memory queue (VLLM_MAX_QUEUE_DEPTH=20) + concurrency semaphore (VLLM_MAX_NUM_SEQS=4); warmup requests (X-Poimen-Warmup: true) sleep WARMUP_DELAY_MS before queue entry; /metrics endpoint wired. Issue #46: rendezvous-hash backend selection on X-Poimen-Cache-Key; round-robin fallback; MarkFailed excludes unhealthy backends 30s; ModifyResponse captures vllm-num-cached-tokens + emits structured log + increments counter. Closes #44 Closes #45 Closes #46
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
package serviceadapter
|
|
|
|
import "os"
|
|
|
|
// NewMemoryAdapter creates a code-registered ServiceAdapter for the memory service.
|
|
// Takes precedence over any config-file loaded memory adapter (main.go skips config
|
|
// adapters when a code-registered one with the same name exists).
|
|
// Upstream URL configured via MEMORY_UPSTREAM_URL env var.
|
|
func NewMemoryAdapter() *ServiceAdapter {
|
|
upstreamURL := os.Getenv("MEMORY_UPSTREAM_URL")
|
|
if upstreamURL == "" {
|
|
upstreamURL = "http://poimen-memory.poimen.svc.cluster.local:8080"
|
|
}
|
|
return &ServiceAdapter{
|
|
Namespace: "poimen",
|
|
ServiceName: "memory",
|
|
Spec: *GetMemorySpec(upstreamURL),
|
|
}
|
|
}
|
|
|
|
// GetMemorySpec returns the ServiceAdapter spec for the memory service.
|
|
func GetMemorySpec(upstreamURL string) *Spec {
|
|
return &Spec{
|
|
ServiceName: "memory",
|
|
Upstream: Upstream{
|
|
URL: upstreamURL,
|
|
TimeoutSeconds: 30,
|
|
},
|
|
Auth: Auth{
|
|
Required: true,
|
|
Capability: "memory:read",
|
|
},
|
|
Resources: []Resource{
|
|
{
|
|
Name: "ingest",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/memory/ingest",
|
|
Auth: &Auth{Required: true, Capability: "memory:write"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "query",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/memory/query",
|
|
Auth: &Auth{Required: true, Capability: "memory:read"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "skills",
|
|
Methods: []Method{{
|
|
Verb: "GET",
|
|
UpstreamPath: "/memory/skills",
|
|
}},
|
|
},
|
|
{
|
|
Name: "standing-context",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/memory/standing-context",
|
|
Auth: &Auth{Required: true, Capability: "memory:read"},
|
|
}},
|
|
},
|
|
},
|
|
}
|
|
}
|