feat(agent): add container runtime support and enhance agent configuration

- Introduced ContainerRuntime field in AgentConfig and AgentEnvConfig.
- Added IterAgents and NumAgents functions for agent pool management.
- Updated agent creation and verification endpoints to handle container runtime.
- Enhanced Docker Compose template to support different container runtimes.
- Added runtime endpoint to retrieve agent runtime information.
This commit is contained in:
yusing
2025-09-13 23:44:03 +08:00
parent 4509622dde
commit 2717dc963a
11 changed files with 158 additions and 28 deletions

View File

@@ -6,15 +6,17 @@ import (
"github.com/yusing/go-proxy/internal/route/provider"
)
func (cfg *Config) VerifyNewAgent(host string, ca agent.PEMPair, client agent.PEMPair) (int, gperr.Error) {
func (cfg *Config) VerifyNewAgent(host string, ca agent.PEMPair, client agent.PEMPair, containerRuntime agent.ContainerRuntime) (int, gperr.Error) {
for _, a := range cfg.value.Providers.Agents {
if a.Addr == host {
return 0, gperr.New("agent already exists")
}
}
var agentCfg agent.AgentConfig
agentCfg.Addr = host
agentCfg := agent.AgentConfig{
Addr: host,
Runtime: containerRuntime,
}
err := agentCfg.StartWithCerts(cfg.Task().Context(), ca.Cert, client.Cert, client.Key)
if err != nil {
return 0, gperr.Wrap(err, "failed to start agent")

View File

@@ -52,7 +52,7 @@ type (
Statistics() map[string]any
RouteProviderList() []RouteProviderListResponse
Context() context.Context
VerifyNewAgent(host string, ca agent.PEMPair, client agent.PEMPair) (int, gperr.Error)
VerifyNewAgent(host string, ca agent.PEMPair, client agent.PEMPair, containerRuntime agent.ContainerRuntime) (int, gperr.Error)
AutoCertProvider() *autocert.Provider
}
)