Documentation
¶
Index ¶
- func Forward(targetURL, proxyURL string, w http.ResponseWriter, r *http.Request) error
- func ForwardMiddleware(cfg ForwardConfig) gin.HandlerFunc
- func ResolveAddress(addresses []Address, addressTag, preferredTag, cacheKey string) (string, error)
- func ResolveProxyURL(agentProxyURL, globalProxyURL string) string
- type Address
- type AgentAddressFetcher
- type AgentResolver
- type ForwardConfig
- type MasterAddressFetcher
- type RouteForwarder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Forward ¶
Forward reverse-proxies the request to the target agent URL. Supports streaming via FlushInterval -1. Strips agent forwarding headers and increments hop counter.
func ForwardMiddleware ¶
func ForwardMiddleware(cfg ForwardConfig) gin.HandlerFunc
ForwardMiddleware checks for X-Vaala-Agent-ID / X-Vaala-Agent-Tag headers and forwards the request to the target agent if found.
func ResolveAddress ¶
ResolveAddress selects the best address for the target agent. Priority: addressTag -> preferredTag -> auto-probe (first reachable, cached 60s).
func ResolveProxyURL ¶
ResolveProxyURL returns the proxy URL to use for forwarding. Priority: per-agent > global default.
Types ¶
type Address ¶
func ParseAddresses ¶
ParseAddresses parses the JSON http_addresses field.
type AgentAddressFetcher ¶
AgentAddressFetcher fetches merged addresses for an agent in agent mode. It combines DB sync with push-updated addresses.
type AgentResolver ¶
AgentResolver resolves an agent by ID or tag.
type ForwardConfig ¶
type ForwardConfig struct {
SelfID string
Resolver AgentResolver
MasterAddrFetcher MasterAddressFetcher // master 模式使用 (新增)
AgentAddrFetcher AgentAddressFetcher // agent 模式使用 (新增)
GlobalProxyURL string
PreferredAddrTag string
IsMaster bool // 区分 master/agent 模式 (新增)
}
ForwardConfig configures the forwarding middleware.
type MasterAddressFetcher ¶
MasterAddressFetcher fetches merged addresses for an agent in master mode. It combines DB config with memory auto-detected addresses.
type RouteForwarder ¶
type RouteForwarder struct {
SelfID string
GetAgent func(agentID string) *models.Agent
GetAgentsByTag func(tag string) []*models.Agent
GlobalProxyURL string
PreferredTag string
}
RouteForwarder holds dependencies needed for ForwardByRoute.
func (*RouteForwarder) ForwardByRoute ¶
func (rf *RouteForwarder) ForwardByRoute(c *gin.Context, route *models.AgentRoute) (bool, error)
ForwardByRoute resolves the target agent from an AgentRoute and forwards the request. Returns true if the request was forwarded, false if it should be processed locally.