Documentation ¶
Overview ¶
Package events provides the events generated by the collectors.
Index ¶
- Constants
- func ManagingOwner(owners []v1.OwnerReference) *v1.OwnerReference
- type Cache
- type CacheEntry
- type Event
- type Interface
- type Resource
- func (g *Resource) AddReferencesForKind(kind string, refs []fields.Reference)
- func (g *Resource) GenerateSubscribers(subs fields.Subscribers) fields.Subscribers
- func (g *Resource) GetMetadata() string
- func (g *Resource) GetResourceReferences() fields.References
- func (g *Resource) GetSpec() string
- func (g *Resource) GetStatus() string
- func (g *Resource) GetSubscribers() fields.Subscribers
- func (g *Resource) SetMeta(meta string)
- func (g *Resource) SetSpec(spec string)
- func (g *Resource) SetStatus(status string)
- func (g *Resource) SetSubscribers(subs fields.Subscribers)
- func (g *Resource) SetUpdate(update bool)
- func (g *Resource) ToEvents() []Interface
Constants ¶
const ( // Create possible type for an event. Create = "Create" // Update possible type for an event. Update = "Update" // Delete possible type for an event. Delete = "Delete" )
Variables ¶
This section is empty.
Functions ¶
func ManagingOwner ¶
func ManagingOwner(owners []v1.OwnerReference) *v1.OwnerReference
ManagingOwner returns the controller owner of the resource if present.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache for resources items. For each resource that is sent to at least a subscriber it is saved in a cache. The cache is useful for this scenarios:
- each time a new subscriber arrives the cache is used to trigger the respective collector for the cached resources. This way the subscriber receives all the existing resources.
- When a resource is deleted we need to know the subscribers that need a Delete event. The cache provides the sayed subscribers.
- When a resource is updated the cache knows the subscribers that need an Update event.
func (*Cache) Add ¶
func (gc *Cache) Add(key string, value *CacheEntry)
Add adds a new item to the cache if it does not exist.
func (*Cache) Get ¶
func (gc *Cache) Get(key string) (*CacheEntry, bool)
Get returns an item from the cache using the provided key.
func (*Cache) Update ¶
func (gc *Cache) Update(key string, value *CacheEntry)
Update updates an item in the cache.
type CacheEntry ¶
type CacheEntry struct { Hash uint64 UID types.UID Refs fields.References Subs fields.Subscribers }
CacheEntry items that can be saved in the cache.
type Event ¶
type Event struct { *metadata.Event Subs fields.Subscribers }
Event generated for watched kubernetes resources.
func (*Event) GRPCMessage ¶
GRPCMessage returns the grpc message ready to be sent over the grpc connection.
func (*Event) ResourceKind ¶
ResourceKind returns the Kind of the resource for which the event has been crafted.
func (*Event) Subscribers ¶
func (ge *Event) Subscribers() fields.Subscribers
Subscribers returns the destination nodes.
type Interface ¶
type Interface interface { Subscribers() fields.Subscribers String() string Type() string ResourceKind() string GRPCMessage() *metadata.Event }
Interface must be satisfied by events generated for each supported k8s resource. Evens are generated by the collectors and sent to the message broker which is in charge to deliver them to all subscribers that have an interest for those events.
type Resource ¶
type Resource struct { Kind string UID string Meta string Spec string Status string // Only used when storing metadata for pods. ResourceReferences fields.References // contains filtered or unexported fields }
Resource event that holds metadata fields for k8s resources.
func (*Resource) AddReferencesForKind ¶
AddReferencesForKind adds references for a given Kind in the pod event.
func (*Resource) GenerateSubscribers ¶
func (g *Resource) GenerateSubscribers(subs fields.Subscribers) fields.Subscribers
GenerateSubscribers populates the subscribers to which the events need to be sent, starting from the given subscribers. The starting point are the cached subscribers to which we already know that we have sent at least a "Create" event. From the cached subscribers and the passed ones it generates the subscribers to which we need to send an event and saves them in the appropriate field, i.e. Resource.createdFor, Resource.updatedFor and Resource.deletedFor. At the same time the Resource.nodes field is updated based on the new added or deleted nodes.
func (*Resource) GetMetadata ¶
GetMetadata returns the metadata field.
func (*Resource) GetResourceReferences ¶
func (g *Resource) GetResourceReferences() fields.References
GetResourceReferences returns refs.
func (*Resource) GetSubscribers ¶
func (g *Resource) GetSubscribers() fields.Subscribers
GetSubscribers returns the nodes.
func (*Resource) SetMeta ¶
SetMeta sets the Meta field if different from the existing one. It also sets to true the "updated" internal variable.
func (*Resource) SetSpec ¶
SetSpec sets the Spec field if different from the existing one. It also sets to true the "updated" internal variable.
func (*Resource) SetStatus ¶
SetStatus sets the Status field if different from the existing one. It also sets to true the "updated" internal variable.
func (*Resource) SetSubscribers ¶
func (g *Resource) SetSubscribers(subs fields.Subscribers)
SetSubscribers populates the nodes to which send the event.