refactor(agent): move agent pool to agent package, rename route.Agent() to route.GetAgent()

This commit is contained in:
yusing
2025-06-14 20:04:39 +08:00
parent cabb840a91
commit 7d17a01de1
13 changed files with 23 additions and 55 deletions

View File

@@ -16,7 +16,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/yusing/go-proxy/agent/pkg/agent"
"github.com/yusing/go-proxy/internal/common"
config "github.com/yusing/go-proxy/internal/config/types"
"github.com/yusing/go-proxy/internal/task"
)
@@ -122,7 +121,7 @@ func NewClient(host string) (*SharedClient, error) {
var dial func(ctx context.Context) (net.Conn, error)
if agent.IsDockerHostAgent(host) {
cfg, ok := config.GetInstance().GetAgent(host)
cfg, ok := agent.GetAgent(host)
if !ok {
panic(fmt.Errorf("agent %q not found", host))
}

View File

@@ -12,7 +12,6 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/go-connections/nat"
"github.com/yusing/go-proxy/agent/pkg/agent"
config "github.com/yusing/go-proxy/internal/config/types"
"github.com/yusing/go-proxy/internal/gperr"
idlewatcher "github.com/yusing/go-proxy/internal/idlewatcher/types"
"github.com/yusing/go-proxy/internal/serialization"
@@ -102,7 +101,7 @@ func FromDocker(c *container.SummaryTrimmed, dockerHost string) (res *Container)
if agent.IsDockerHostAgent(dockerHost) {
var ok bool
res.Agent, ok = config.GetInstance().GetAgent(dockerHost)
res.Agent, ok = agent.GetAgent(dockerHost)
if !ok {
res.addError(fmt.Errorf("agent %q not found", dockerHost))
}