Files
homelab-frontend/internal/serviceadapter/memory_adapter.go
T

68 lines
1.7 KiB
Go
Raw Normal View History

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"},
}},
},
},
}
}