refactor(agent): extract agent pool and HTTP utilities to dedicated package

Moved non-agent-specific logic from agent/pkg/agent/ to internal/agentpool/:
- pool.go: Agent pool management (Get, Add, Remove, List, Iter, etc.)
- http_requests.go: HTTP utilities (health checks, forwarding, websockets, reverse proxy)
- agent.go: Agent struct with HTTP client management

This separates general-purpose pool management from agent-specific configuration,
improving code organization and making the agent package focused on agent config only.
This commit is contained in:
yusing
2026-01-08 12:02:21 +08:00
parent 751d73da7c
commit db2eda49f1
21 changed files with 380 additions and 322 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"github.com/yusing/godoxy/agent/pkg/agent"
"github.com/yusing/godoxy/internal/agentpool"
"github.com/yusing/godoxy/internal/serialization"
"github.com/yusing/godoxy/internal/types"
gperr "github.com/yusing/goutils/errs"
@@ -71,7 +72,7 @@ func FromDocker(c *container.Summary, dockerCfg types.DockerProviderConfig) (res
if agent.IsDockerHostAgent(dockerCfg.URL) {
var ok bool
res.Agent, ok = agent.GetAgent(dockerCfg.URL)
res.Agent, ok = agentpool.Get(dockerCfg.URL)
if !ok {
addError(res, fmt.Errorf("agent %q not found", dockerCfg.URL))
}