Implement caching for remote instance proxies and enhance proxy request handling

This commit is contained in:
2025-10-07 18:44:23 +02:00
parent 554796391b
commit aae3f84d49
2 changed files with 57 additions and 51 deletions

View File

@@ -4,6 +4,8 @@ import (
"llamactl/pkg/config"
"llamactl/pkg/manager"
"net/http"
"net/http/httputil"
"sync"
"time"
)
@@ -11,6 +13,8 @@ type Handler struct {
InstanceManager manager.InstanceManager
cfg config.AppConfig
httpClient *http.Client
remoteProxies map[string]*httputil.ReverseProxy // Cache of remote proxies by instance name
remoteProxiesMu sync.RWMutex
}
func NewHandler(im manager.InstanceManager, cfg config.AppConfig) *Handler {
@@ -20,5 +24,6 @@ func NewHandler(im manager.InstanceManager, cfg config.AppConfig) *Handler {
httpClient: &http.Client{
Timeout: 30 * time.Second,
},
remoteProxies: make(map[string]*httputil.ReverseProxy),
}
}