grouping

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupEntityController

type GroupEntityController struct {
	// contains filtered or unexported fields
}

func NewGroupEntityController

func NewGroupEntityController(groupEntityIndex *GroupEntityIndex,
	podInformer coreinformers.PodInformer,
	namespaceInformer coreinformers.NamespaceInformer,
	externalEntityInformer crdv1a2informers.ExternalEntityInformer) *GroupEntityController

func (*GroupEntityController) Run

func (c *GroupEntityController) Run(stopCh <-chan struct{})

type GroupEntityIndex

type GroupEntityIndex struct {
	// contains filtered or unexported fields
}

GroupEntityIndex implements Interface.

It abstracts label set and label selector from entities and groups and does actual matching against the formers to avoid redundant calculation given that most entities (Pod or ExternalEntity) actually share labels. For example, Pods that managed by a deployment controller have same labels.

It maintains indexes between label set and label selector so that querying label sets that match a label selector and reversed queries can be performed with a constant time complexity. Indirectly, querying entities that match a group and reversed queries can be performed with same complexity.

The relationship of the four items are like below: entityItem <===> labelItem <===> selectorItem <===> groupItem

func NewGroupEntityIndex

func NewGroupEntityIndex() *GroupEntityIndex

NewGroupEntityIndex creates a GroupEntityIndex.

func (*GroupEntityIndex) AddEventHandler

func (i *GroupEntityIndex) AddEventHandler(groupType GroupType, handler eventHandler)

func (*GroupEntityIndex) AddExternalEntity

func (i *GroupEntityIndex) AddExternalEntity(ee *v1alpha2.ExternalEntity)

func (*GroupEntityIndex) AddGroup

func (i *GroupEntityIndex) AddGroup(groupType GroupType, name string, selector *types.GroupSelector)

func (*GroupEntityIndex) AddNamespace

func (i *GroupEntityIndex) AddNamespace(namespace *v1.Namespace)

func (*GroupEntityIndex) AddPod

func (i *GroupEntityIndex) AddPod(pod *v1.Pod)

func (*GroupEntityIndex) DeleteExternalEntity

func (i *GroupEntityIndex) DeleteExternalEntity(ee *v1alpha2.ExternalEntity)

func (*GroupEntityIndex) DeleteGroup

func (i *GroupEntityIndex) DeleteGroup(groupType GroupType, name string)

func (*GroupEntityIndex) DeleteNamespace

func (i *GroupEntityIndex) DeleteNamespace(namespace *v1.Namespace)

func (*GroupEntityIndex) DeletePod

func (i *GroupEntityIndex) DeletePod(pod *v1.Pod)

func (*GroupEntityIndex) GetEntities

func (i *GroupEntityIndex) GetEntities(groupType GroupType, name string) ([]*v1.Pod, []*v1alpha2.ExternalEntity)

func (*GroupEntityIndex) GetGroupsForExternalEntity

func (i *GroupEntityIndex) GetGroupsForExternalEntity(namespace, name string) (map[GroupType][]string, bool)

func (*GroupEntityIndex) GetGroupsForPod

func (i *GroupEntityIndex) GetGroupsForPod(namespace, name string) (map[GroupType][]string, bool)

func (*GroupEntityIndex) HasSynced

func (i *GroupEntityIndex) HasSynced() bool

func (*GroupEntityIndex) Run

func (i *GroupEntityIndex) Run(stopCh <-chan struct{})

type GroupType

type GroupType string

GroupType is a public type used to differentiate Groups.

type Interface

type Interface interface {
	// AddGroup adds or updates a group to the index. The caller can then get entities selected by this group.
	AddGroup(groupType GroupType, name string, selector *types.GroupSelector)
	// DeleteGroup deletes a group from the index.
	DeleteGroup(groupType GroupType, name string)
	// AddEventHandler registers an eventHandler for the given type of groups. When any Pod/ExternelEntity/Namespace
	// update affects the given kind of groups, the eventHandler will be called with the affected groups.
	// The eventHandler is supposed to execute quickly and not perform blocking operation. Blocking operation should be
	// deferred to a routine that is triggered by the eventHandler, like the eventHandler + workqueue pattern.
	AddEventHandler(groupType GroupType, handler eventHandler)
	// GetEntities returns the selected Pods or ExternalEntities for the given group.
	GetEntities(groupType GroupType, name string) ([]*v1.Pod, []*v1alpha2.ExternalEntity)
	// GetGroupsForPod returns the groups that select the given Pod.
	GetGroupsForPod(namespace, name string) (map[GroupType][]string, bool)
	// GetGroupsForExternalEntity returns the groups that select the given ExternalEntity.
	GetGroupsForExternalEntity(namespace, name string) (map[GroupType][]string, bool)
	// AddPod adds or updates a Pod to the index. If any existing groups are affected, eventHandlers will be called with
	// the affected groups.
	AddPod(pod *v1.Pod)
	// DeletePod deletes a Pod from the index. If any existing groups are affected, eventHandlers will be called with
	// the affected groups.
	DeletePod(pod *v1.Pod)
	// AddExternalEntity adds or updates an ExternalEntity to the index. If any existing groups are affected,
	// eventHandlers will be called with the affected groups.
	AddExternalEntity(ee *v1alpha2.ExternalEntity)
	// DeleteExternalEntity deletes an ExternalEntity from the index. If any existing groups are affected, eventHandlers
	// will be called with the affected groups.
	DeleteExternalEntity(ee *v1alpha2.ExternalEntity)
	// AddNamespace adds or updates a Namespace to the index. If any existing groups are affected, eventHandlers will be
	// called with the affected groups.
	AddNamespace(namespace *v1.Namespace)
	// DeleteNamespace deletes a Namespace to the index. If any existing groups are affected, eventHandlers will be
	// called with the affected groups.
	DeleteNamespace(namespace *v1.Namespace)
	// Run starts the index.
	Run(stopCh <-chan struct{})
	// HasSynced returns true if the interface has been initialized with the full lists of Pods, Namespaces, and
	// ExternalEntities.
	HasSynced() bool
}

Interface provides methods to query entities that a given group selects and groups that select a given entity. It maintains indexes between groups and entities to make the query efficient. It supports callers to register callbacks that will be called when a specific type of groups' entities are updated.

Jump to

Keyboard shortcuts

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