Files
go-sip/internal/config/current_agent_endpoints.go
T

26 lines
836 B
Go

package config
import (
"errors"
"strings"
)
// LoadCurrentMockAgentEndpoint accepts exactly the one deployment-owned local
// Agent assigned to the isolated Dispatcher. SaaS task data cannot override it.
func LoadCurrentMockAgentEndpoint(filename string) (AgentEndpoint, error) {
if strings.TrimSpace(filename) == "" {
return AgentEndpoint{}, errors.New("DISPATCHER_AGENT_ENDPOINTS_FILE is required")
}
endpoints, err := LoadAgentEndpoints(filename)
if err != nil {
return AgentEndpoint{}, err
}
if len(endpoints) != 1 {
return AgentEndpoint{}, errors.New("current Mock Dispatcher requires exactly one assigned Agent endpoint")
}
if !localGRPCAddress(endpoints[0].Address, false) {
return AgentEndpoint{}, errors.New("current Mock Agent endpoint must be local with an explicit port")
}
return endpoints[0], nil
}