Documentation ¶
Index ¶
- Variables
- type Endpoint
- func (e *Endpoint) Address() net.IP
- func (e *Endpoint) Equals(endpoint *Endpoint) bool
- func (e *Endpoint) ID() string
- func (e *Endpoint) IsTargetPod() bool
- func (e *Endpoint) KubeAPIV1Endpoints() *api.Endpoints
- func (e *Endpoint) KubeAPIV1EndpointsName() string
- func (e *Endpoint) NodeName() *string
- func (e *Endpoint) Port() uint16
- func (e *Endpoint) PortName() string
- func (e *Endpoint) Ready() bool
- func (e *Endpoint) Service() *Service
- func (e *Endpoint) SetService(svc *Service)
- func (e *Endpoint) TargetRef() *api.ObjectReference
- func (e *Endpoint) TargetRefString() string
- type EndpointOnChangeHandler
- type EndpointOption
- type MapServiceManager
- func (sm *MapServiceManager) Add(svc *Service, handlers ...ServiceOnChangeHandler) (err error)
- func (sm *MapServiceManager) Exists(svc *Service) bool
- func (sm *MapServiceManager) Get(svcID string) (svc *Service, err error)
- func (sm *MapServiceManager) List() (list []*Service)
- func (sm *MapServiceManager) ListServicesWithAddress() (list []*Service)
- func (sm *MapServiceManager) Remove(svc *Service, handlers ...ServiceOnChangeHandler) (err error)
- func (sm *MapServiceManager) RemoveByID(svcID string, handlers ...ServiceOnChangeHandler) (err error)
- func (sm *MapServiceManager) RemoveExistingServicesNoLongerCurrent(currentServices []*Service, existingServices []*Service, ...) (err error)
- func (sm *MapServiceManager) RemoveServicesRecursively(svcs []*Service, svcOnChangeHandler []ServiceOnChangeHandler, ...) error
- func (sm *MapServiceManager) ResolveByKubeMetaNamespaceKey(key string) (svcs []*Service, err error)
- func (sm *MapServiceManager) Update(svc *Service, handlers ...ServiceOnChangeHandler) (updated bool, prevSvc *Service, err error)
- func (sm *MapServiceManager) UpdateServicesRecursively(svcs []*Service, endpoints []*Endpoint, ...) error
- type Service
- func (s *Service) Add(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
- func (s *Service) Address() *net.IP
- func (s *Service) Annotations() map[string]string
- func (s *Service) Equals(svc *Service) bool
- func (s *Service) Exists(e *Endpoint) (exists bool)
- func (s *Service) Get(endpointID string) (e *Endpoint, err error)
- func (s *Service) ID() string
- func (s *Service) IsChildEndpoint(e *Endpoint) bool
- func (s *Service) KubeAPIV1Service() *api.Service
- func (s *Service) KubeAPIV1ServiceName() string
- func (s *Service) List() (endpoints []*Endpoint)
- func (s *Service) Port() uint16
- func (s *Service) PortName() string
- func (s *Service) ProtoNumber() uint16
- func (s *Service) Protocol() api.Protocol
- func (s *Service) Remove(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
- func (s *Service) TargetPort() *uint16
- func (s *Service) Update(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
- func (s *Service) UpdateEndpoints(endpoints []*Endpoint, handlers ...EndpointOnChangeHandler) (result *ServiceUpdateRecord, err error)
- func (s *Service) UpsertEndpoints(endpoints []*Endpoint, handlers ...EndpointOnChangeHandler) (result *ServiceUpdateRecord, err error)
- type ServiceManager
- type ServiceOnChangeHandler
- type ServiceOption
- type ServiceUpdateRecord
Constants ¶
This section is empty.
Variables ¶
var ProtoNameToNumberMap = map[api.Protocol]uint16{ api.ProtocolTCP: syscall.IPPROTO_TCP, api.ProtocolUDP: syscall.IPPROTO_UDP, }
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func ConvertKubeAPIV1EndpointsToEndpoints ¶
func ConvertKubeAPIV1EndpointsToEndpoints(kubeEndpoints *api.Endpoints) (endpoints []*Endpoint, err error)
ConvertKubeAPIV1EndpointsToEndpoints translates kubernetes endpoints objects to balanced endpoints
func NewEndpoint ¶
func NewEndpoint(kubeEndpoints *api.Endpoints, kubeEndpointAddress *api.EndpointAddress, kubeEndpointPort *api.EndpointPort, opts ...EndpointOption) (*Endpoint, error)
func (*Endpoint) IsTargetPod ¶
func (*Endpoint) KubeAPIV1Endpoints ¶
func (*Endpoint) KubeAPIV1EndpointsName ¶
func (*Endpoint) SetService ¶
func (*Endpoint) TargetRef ¶
func (e *Endpoint) TargetRef() *api.ObjectReference
func (*Endpoint) TargetRefString ¶
type EndpointOnChangeHandler ¶
type EndpointOption ¶
func Readiness ¶
func Readiness(ready bool) EndpointOption
type MapServiceManager ¶
type MapServiceManager struct {
// contains filtered or unexported fields
}
func NewMapServiceManager ¶
func NewMapServiceManager(logger util.Logger) *MapServiceManager
func (*MapServiceManager) Add ¶
func (sm *MapServiceManager) Add(svc *Service, handlers ...ServiceOnChangeHandler) (err error)
func (*MapServiceManager) Exists ¶
func (sm *MapServiceManager) Exists(svc *Service) bool
func (*MapServiceManager) Get ¶
func (sm *MapServiceManager) Get(svcID string) (svc *Service, err error)
func (*MapServiceManager) List ¶
func (sm *MapServiceManager) List() (list []*Service)
func (*MapServiceManager) ListServicesWithAddress ¶
func (sm *MapServiceManager) ListServicesWithAddress() (list []*Service)
func (*MapServiceManager) Remove ¶
func (sm *MapServiceManager) Remove(svc *Service, handlers ...ServiceOnChangeHandler) (err error)
func (*MapServiceManager) RemoveByID ¶
func (sm *MapServiceManager) RemoveByID(svcID string, handlers ...ServiceOnChangeHandler) (err error)
func (*MapServiceManager) RemoveExistingServicesNoLongerCurrent ¶
func (sm *MapServiceManager) RemoveExistingServicesNoLongerCurrent(currentServices []*Service, existingServices []*Service, handlers ...ServiceOnChangeHandler) (err error)
RemoveExistingServicesNoLongerCurrent removes existing services that are managed by the MapServiceManager that are no longer in existence in the real world
func (*MapServiceManager) RemoveServicesRecursively ¶
func (sm *MapServiceManager) RemoveServicesRecursively(svcs []*Service, svcOnChangeHandler []ServiceOnChangeHandler, eOnChangeHandler []EndpointOnChangeHandler) error
RemoveServicesRecursively remove Endpoints of a Service first before removal
func (*MapServiceManager) ResolveByKubeMetaNamespaceKey ¶
func (sm *MapServiceManager) ResolveByKubeMetaNamespaceKey(key string) (svcs []*Service, err error)
ResolveByKubeMetaNamespaceKey : finds all Services with the same Kubernetes Service Object Key
func (*MapServiceManager) Update ¶
func (sm *MapServiceManager) Update(svc *Service, handlers ...ServiceOnChangeHandler) (updated bool, prevSvc *Service, err error)
func (*MapServiceManager) UpdateServicesRecursively ¶
func (sm *MapServiceManager) UpdateServicesRecursively(svcs []*Service, endpoints []*Endpoint, svcOnChangeHandler []ServiceOnChangeHandler, eOnChangeHandler []EndpointOnChangeHandler) error
UpdateServicesRecursively will add Service to SM if not already exist and its Endpoints, otherwise, it will update the existing Service in the SM along with its Endpoints
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func ConvertKubeAPIV1ServiceToServices ¶
func ConvertKubeAPIV1ServiceToServices(kubeService *api.Service, opts ...ServiceOption) ([]*Service, error)
ConvertKubeAPIV1ServiceToServices assumes a kubeService with Service Type: LoadBalancer
func NewService ¶
func NewService(kubeService *api.Service, portSpec api.ServicePort, opts ...ServiceOption) (*Service, error)
func (*Service) Add ¶
func (s *Service) Add(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
func (*Service) Annotations ¶
func (*Service) IsChildEndpoint ¶
func (*Service) KubeAPIV1Service ¶
func (*Service) KubeAPIV1ServiceName ¶
func (*Service) ProtoNumber ¶
func (*Service) Remove ¶
func (s *Service) Remove(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
func (*Service) TargetPort ¶
TargetPort resolves target port using endpoint information
func (*Service) Update ¶
func (s *Service) Update(e *Endpoint, handlers ...EndpointOnChangeHandler) (err error)
func (*Service) UpdateEndpoints ¶
func (s *Service) UpdateEndpoints(endpoints []*Endpoint, handlers ...EndpointOnChangeHandler) (result *ServiceUpdateRecord, err error)
UpdateEndpoints : will insert or update endpoints similarly to UpsertEndpoints, but will remove children that do not exist in endpoints slice
func (*Service) UpsertEndpoints ¶
func (s *Service) UpsertEndpoints(endpoints []*Endpoint, handlers ...EndpointOnChangeHandler) (result *ServiceUpdateRecord, err error)
UpsertEndpoints : will only insert or update endpoints that are a child of this Service, ignore the rest
type ServiceManager ¶
type ServiceManager interface { Exists(svc *Service) bool // ResolveByKubeMetaNamespaceKey : finds all Services with the same Kubernetes Service Object Key ResolveByKubeMetaNamespaceKey(key string) (svcs []*Service, err error) // RemoveExistingServicesNoLongerCurrent removes existing services that are managed by the MapServiceManager that are no longer in existence in the real world RemoveExistingServicesNoLongerCurrent(currentServices []*Service, existingServices []*Service, handlers ...ServiceOnChangeHandler) (err error) Get(svcID string) (svc *Service, err error) List() (list []*Service) ListServicesWithAddress() (list []*Service) Add(svc *Service, handlers ...ServiceOnChangeHandler) (err error) Update(svc *Service, handlers ...ServiceOnChangeHandler) (updated bool, prevSvc *Service, err error) Remove(svc *Service, handlers ...ServiceOnChangeHandler) (err error) RemoveByID(svcID string, handlers ...ServiceOnChangeHandler) (err error) // RemoveServicesRecursively remove Endpoints of a Service first before removal RemoveServicesRecursively(svcs []*Service, svcOnChangeHandler []ServiceOnChangeHandler, eOnChangeHandler []EndpointOnChangeHandler) error // UpdateServicesRecursively will add Service to SM if not already exist and its Endpoints, // otherwise, it will update the existing Service in the SM along with its Endpoints UpdateServicesRecursively(svcs []*Service, endpoints []*Endpoint, svcOnChangeHandler []ServiceOnChangeHandler, eOnChangeHandler []EndpointOnChangeHandler) error }
ServiceManager manages balanced Service objects