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

@@ -4,7 +4,7 @@ import (
"github.com/bytedance/sonic"
"github.com/moby/moby/api/types/container"
"github.com/yusing/ds/ordered"
"github.com/yusing/godoxy/agent/pkg/agent"
"github.com/yusing/godoxy/internal/agentpool"
gperr "github.com/yusing/goutils/errs"
)
@@ -20,7 +20,7 @@ type (
State container.ContainerState `json:"state"`
Agent *agent.AgentConfig `json:"agent"`
Agent *agentpool.Agent `json:"agent"`
Labels map[string]string `json:"-"` // for creating routes
ActualLabels map[string]string `json:"labels"` // for displaying in UI

View File

@@ -3,7 +3,7 @@ package types
import (
"net/http"
"github.com/yusing/godoxy/agent/pkg/agent"
"github.com/yusing/godoxy/internal/agentpool"
"github.com/yusing/godoxy/internal/homepage"
nettypes "github.com/yusing/godoxy/internal/net/types"
provider "github.com/yusing/godoxy/internal/route/provider/types"
@@ -35,7 +35,7 @@ type (
DisplayName() string
ContainerInfo() *Container
GetAgent() *agent.AgentConfig
GetAgent() *agentpool.Agent
IsDocker() bool
IsAgent() bool