Documentation ¶
Index ¶
- Variables
- func GetPortHTTP(service *model.Service) *model.Port
- func MakeExternalHTTPSService(hostname, external model.Hostname, address string) *model.Service
- func MakeExternalHTTPService(hostname, external model.Hostname, address string) *model.Service
- func MakeIP(service *model.Service, version int) string
- func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
- func MakeService(hostname model.Hostname, address string) *model.Service
- type ServiceDiscovery
- func (sd *ServiceDiscovery) AddService(name model.Hostname, svc *model.Service)
- func (sd *ServiceDiscovery) ClearErrors()
- func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
- func (sd *ServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) GetService(hostname model.Hostname) (*model.Service, error)
- func (sd *ServiceDiscovery) GetServiceAttributes(hostname model.Hostname) (*model.ServiceAttributes, error)
- func (sd *ServiceDiscovery) Instances(hostname model.Hostname, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) InstancesByPort(hostname model.Hostname, num int, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
- func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
- func (sd *ServiceDiscovery) Services() ([]*model.Service, error)
- func (sd *ServiceDiscovery) WorkloadHealthCheckInfo(addr string) model.ProbeList
Constants ¶
This section is empty.
Variables ¶
var ( // HelloService is a mock service with `hello.default.svc.cluster.local` as // a hostname and `10.1.0.0` for ip HelloService = MakeService("hello.default.svc.cluster.local", "10.1.0.0") // WorldService is a mock service with `world.default.svc.cluster.local` as // a hostname and `10.2.0.0` for ip WorldService = MakeService("world.default.svc.cluster.local", "10.2.0.0") // ExtHTTPService is a mock external HTTP service ExtHTTPService = MakeExternalHTTPService("httpbin.default.svc.cluster.local", "httpbin.org", "") // ExtHTTPSService is a mock external HTTPS service ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local", "httpbin.org", "") // HelloInstanceV0 is a mock IP address for v0 of HelloService HelloInstanceV0 = MakeIP(HelloService, 0) // HelloInstanceV1 is a mock IP address for v1 of HelloService HelloInstanceV1 = MakeIP(HelloService, 1) // HelloProxyV0 is a mock proxy v0 of HelloService HelloProxyV0 = model.Proxy{ Type: model.Sidecar, IPAddress: HelloInstanceV0, ID: "v0.default", Domain: "default.svc.cluster.local", } // HelloProxyV1 is a mock proxy v1 of HelloService HelloProxyV1 = model.Proxy{ Type: model.Sidecar, IPAddress: HelloInstanceV1, ID: "v1.default", Domain: "default.svc.cluster.local", } // Ingress is a mock proxy to IP 10.3.3.3 Ingress = model.Proxy{ Type: model.Ingress, IPAddress: "10.3.3.3", ID: "ingress.default", Domain: "default.svc.cluster.local", } // MockDiscovery is an in-memory ServiceDiscover with mock services MockDiscovery = &ServiceDiscovery{ services: map[model.Hostname]*model.Service{ HelloService.Hostname: HelloService, WorldService.Hostname: WorldService, ExtHTTPService.Hostname: ExtHTTPService, ExtHTTPSService.Hostname: ExtHTTPSService, }, versions: 2, } )
var (
// PortHTTPName is the HTTP port name
PortHTTPName = "http"
)
Functions ¶
func GetPortHTTP ¶
GetPortHTTP returns the port which name is PortHTTPName. Returns nil if such a port does not exist (should not happenen if service is create via memory MakeSericve)
func MakeExternalHTTPSService ¶
MakeExternalHTTPSService creates memory external service
func MakeExternalHTTPService ¶
MakeExternalHTTPService creates memory external service
func MakeInstance ¶
func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance
MakeInstance creates a memory instance, version enumerates endpoints
Types ¶
type ServiceDiscovery ¶
type ServiceDiscovery struct { WantGetProxyServiceInstances []*model.ServiceInstance ServicesError error GetServiceError error InstancesError error GetProxyServiceInstancesError error // contains filtered or unexported fields }
ServiceDiscovery is a memory discovery interface
func NewDiscovery ¶
NewDiscovery builds a memory ServiceDiscovery
func (*ServiceDiscovery) AddService ¶
func (sd *ServiceDiscovery) AddService(name model.Hostname, svc *model.Service)
AddService will add to the registry the provided service
func (*ServiceDiscovery) ClearErrors ¶
func (sd *ServiceDiscovery) ClearErrors()
ClearErrors clear errors used for failures during model.ServiceDiscovery interface methods
func (*ServiceDiscovery) GetIstioServiceAccounts ¶
func (sd *ServiceDiscovery) GetIstioServiceAccounts(hostname model.Hostname, ports []string) []string
GetIstioServiceAccounts gets the Istio service accounts for a service hostname.
func (*ServiceDiscovery) GetProxyServiceInstances ¶
func (sd *ServiceDiscovery) GetProxyServiceInstances(node *model.Proxy) ([]*model.ServiceInstance, error)
GetProxyServiceInstances implements discovery interface
func (*ServiceDiscovery) GetService ¶
GetService implements discovery interface
func (*ServiceDiscovery) GetServiceAttributes ¶
func (sd *ServiceDiscovery) GetServiceAttributes(hostname model.Hostname) (*model.ServiceAttributes, error)
GetServiceAttributes retrieves namespace of a service if it exists.
func (*ServiceDiscovery) Instances ¶
func (sd *ServiceDiscovery) Instances(hostname model.Hostname, ports []string, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
Instances implements discovery interface
func (*ServiceDiscovery) InstancesByPort ¶
func (sd *ServiceDiscovery) InstancesByPort(hostname model.Hostname, num int, labels model.LabelsCollection) ([]*model.ServiceInstance, error)
InstancesByPort implements discovery interface
func (*ServiceDiscovery) ManagementPorts ¶
func (sd *ServiceDiscovery) ManagementPorts(addr string) model.PortList
ManagementPorts implements discovery interface
func (*ServiceDiscovery) Services ¶
func (sd *ServiceDiscovery) Services() ([]*model.Service, error)
Services implements discovery interface
func (*ServiceDiscovery) WorkloadHealthCheckInfo ¶
func (sd *ServiceDiscovery) WorkloadHealthCheckInfo(addr string) model.ProbeList
WorkloadHealthCheckInfo implements discovery interface