mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-29 05:11:51 +02:00
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:
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/internal/agentpool"
|
||||
config "github.com/yusing/godoxy/internal/config/types"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/homepage"
|
||||
@@ -95,7 +95,7 @@ type (
|
||||
|
||||
provider types.RouteProvider
|
||||
|
||||
agent *agent.AgentConfig
|
||||
agent *agentpool.Agent
|
||||
|
||||
started chan struct{}
|
||||
onceStart sync.Once
|
||||
@@ -154,10 +154,10 @@ func (r *Route) validate() gperr.Error {
|
||||
}
|
||||
var ok bool
|
||||
// by agent address
|
||||
r.agent, ok = agent.GetAgent(r.Agent)
|
||||
r.agent, ok = agentpool.Get(r.Agent)
|
||||
if !ok {
|
||||
// fallback to get agent by name
|
||||
r.agent, ok = agent.GetAgentByName(r.Agent)
|
||||
r.agent, ok = agentpool.GetAgent(r.Agent)
|
||||
if !ok {
|
||||
return gperr.Errorf("agent %s not found", r.Agent)
|
||||
}
|
||||
@@ -511,7 +511,7 @@ func (r *Route) Type() route.RouteType {
|
||||
panic(fmt.Errorf("unexpected scheme %s for alias %s", r.Scheme, r.Alias))
|
||||
}
|
||||
|
||||
func (r *Route) GetAgent() *agent.AgentConfig {
|
||||
func (r *Route) GetAgent() *agentpool.Agent {
|
||||
if r.Container != nil && r.Container.Agent != nil {
|
||||
return r.Container.Agent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user