Files
godoxy-yusing/internal/types/routes.go
yusing 8b5cb947c8 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.
2026-01-08 12:02:21 +08:00

78 lines
1.8 KiB
Go

package types
import (
"net/http"
"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"
gperr "github.com/yusing/goutils/errs"
"github.com/yusing/goutils/http/reverseproxy"
"github.com/yusing/goutils/pool"
"github.com/yusing/goutils/task"
)
type (
Route interface {
task.TaskStarter
task.TaskFinisher
pool.Object
ProviderName() string
GetProvider() RouteProvider
TargetURL() *nettypes.URL
HealthMonitor() HealthMonitor
SetHealthMonitor(m HealthMonitor)
References() []string
ShouldExclude() bool
Started() <-chan struct{}
IdlewatcherConfig() *IdlewatcherConfig
HealthCheckConfig() HealthCheckConfig
LoadBalanceConfig() *LoadBalancerConfig
HomepageItem() homepage.Item
DisplayName() string
ContainerInfo() *Container
GetAgent() *agentpool.Agent
IsDocker() bool
IsAgent() bool
UseLoadBalance() bool
UseIdleWatcher() bool
UseHealthCheck() bool
UseAccessLog() bool
}
HTTPRoute interface {
Route
http.Handler
}
ReverseProxyRoute interface {
HTTPRoute
ReverseProxy() *reverseproxy.ReverseProxy
}
FileServerRoute interface {
HTTPRoute
RootPath() string
}
StreamRoute interface {
Route
nettypes.Stream
Stream() nettypes.Stream
}
RouteProvider interface {
Start(task.Parent) gperr.Error
LoadRoutes() gperr.Error
GetRoute(alias string) (r Route, ok bool)
// should be used like `for _, r := range p.IterRoutes` (no braces), not calling it directly
IterRoutes(yield func(alias string, r Route) bool)
NumRoutes() int
FindService(project, service string) (r Route, ok bool)
Statistics() ProviderStats
GetType() provider.Type
ShortName() string
String() string
}
)