memory

package
v0.0.0-...-4638b96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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",
		true, "")

	// ExtHTTPSService is a mock external HTTPS service
	ExtHTTPSService = MakeExternalHTTPSService("httpsbin.default.svc.cluster.local",
		true, "")

	// 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.SidecarProxy,
		IPAddresses: []string{HelloInstanceV0},
		ID:          "v0.default",
		DNSDomain:   "default.svc.cluster.local",
	}

	// HelloProxyV1 is a mock proxy v1 of HelloService
	HelloProxyV1 = model.Proxy{
		Type:        model.SidecarProxy,
		IPAddresses: []string{HelloInstanceV1},
		ID:          "v1.default",
		DNSDomain:   "default.svc.cluster.local",
	}

	// Ingress is a mock proxy to IP 10.3.3.3
	Ingress = model.Proxy{
		Type:        model.Ingress,
		IPAddresses: []string{"10.3.3.3"},
		ID:          "ingress.default",
		DNSDomain:   "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,
	}
)
View Source
var (
	// PortHTTPName is the HTTP port name
	PortHTTPName = "http"
)

Functions

func GetPortHTTP

func GetPortHTTP(service *model.Service) *model.Port

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

func MakeExternalHTTPSService(hostname model.Hostname, isMeshExternal bool, address string) *model.Service

MakeExternalHTTPSService creates memory external service

func MakeExternalHTTPService

func MakeExternalHTTPService(hostname model.Hostname, isMeshExternal bool, address string) *model.Service

MakeExternalHTTPService creates memory external service

func MakeIP

func MakeIP(service *model.Service, version int) string

MakeIP creates a fake IP address for a service and instance version

func MakeInstance

func MakeInstance(service *model.Service, port *model.Port, version int, az string) *model.ServiceInstance

MakeInstance creates a memory instance, version enumerates endpoints

func MakeService

func MakeService(hostname model.Hostname, address string) *model.Service

MakeService creates a memory service

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

func NewDiscovery(services map[model.Hostname]*model.Service, versions int) *ServiceDiscovery

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 []int) []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) GetProxyWorkloadLabels

func (sd *ServiceDiscovery) GetProxyWorkloadLabels(proxy *model.Proxy) (model.LabelsCollection, error)

func (*ServiceDiscovery) GetService

func (sd *ServiceDiscovery) GetService(hostname model.Hostname) (*model.Service, error)

GetService 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL