serviceregistry

package
v10.104.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependentServiceData

type DependentServiceData struct {
	// Used for authorization
	APICache *urisearch.APICache
	// Used by the protomux to find the right service type.
	ServiceType common.ListenerType
}

DependentServiceData are the data that are held for each service in the dependentServiceCache.

type PortContext

type PortContext struct {
	ID                 string
	Type               common.ListenerType
	Service            *policy.ApplicationService
	Authorizer         *auth.Processor
	PUContext          *pucontext.PUContext
	TargetPort         int
	ClientTrustedRoots *x509.CertPool
}

PortContext includes all the needed associations to refer to a service by port. For incoming connections the only available information is the IP/port pair of the original request and we use this to map the connection and request to a port. For network services we have additional state data such as the authorizers. Note that there is one PortContext for every service of every PU.

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Registry is a service registry. It maintains all the state information and provides a simple API to retrieve the data. The registry always locks and allows multi-threading.

func NewServiceRegistry

func NewServiceRegistry() *Registry

NewServiceRegistry creates and initializes the registry.

func (*Registry) Register

func (r *Registry) Register(
	puID string,
	pu *policy.PUInfo,
	puContext *pucontext.PUContext,
	secrets secrets.Secrets,
) (*ServiceContext, error)

Register registers a new service with the registry. If the service already exists it updates the service with the new information, otherwise it creates a new service.

func (*Registry) RetrieveExposedServiceContext

func (r *Registry) RetrieveExposedServiceContext(ip net.IP, port int, host string) (*PortContext, error)

RetrieveExposedServiceContext retrieves a service by the provided IP and or port. This is called by the network side of processing to find the context.

func (*Registry) RetrieveServiceByID

func (r *Registry) RetrieveServiceByID(id string) (*ServiceContext, error)

RetrieveServiceByID retrieves a service by the PU ID. Returns error if not found.

func (*Registry) RetrieveServiceDataByIDAndNetwork

func (r *Registry) RetrieveServiceDataByIDAndNetwork(id string, ip net.IP, port int, host string) (*ServiceContext, *DependentServiceData, error)

RetrieveServiceDataByIDAndNetwork will return the service data that match the given PU and the given IP/port information.

func (*Registry) Unregister

func (r *Registry) Unregister(puID string) error

Unregister unregisters a pu from the registry.

type ServiceContext

type ServiceContext struct {
	PU        *policy.PUInfo
	PUContext *pucontext.PUContext
	RootCA    [][]byte
	// contains filtered or unexported fields
}

ServiceContext includes all the all the service related information for dependent services. It is indexed by the PU ID and a PU can easily retrieve all the state with a simple lookup. Note, that there is one ServiceContext for every PU.

Jump to

Keyboard shortcuts

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