Documentation
¶
Index ¶
- func Merge(originalService, mergedService *entitycachev1.Service)
- func ServiceIDsFromEntity(entity *Entity) []services.ServiceID
- type Entity
- type EntityCache
- func (c *EntityCache) Clear()
- func (c *EntityCache) DumpHandler(w http.ResponseWriter, req *http.Request)
- func (c *EntityCache) GetByIP(entityIP string) *Entity
- func (c *EntityCache) GetByName(entityName string) *Entity
- func (c *EntityCache) Put(entity *Entity)
- func (c *EntityCache) Remove(entity *Entity) bool
- func (c *EntityCache) Services() *entitycachev1.EntityCache
- type EntityID
- type FxIn
- type ServiceKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge(originalService, mergedService *entitycachev1.Service)
Merge merges `mergedService` into `originalService`. This sums `EntitiesCount`.
func ServiceIDsFromEntity ¶
ServiceIDsFromEntity returns a list of services the entity is a part of.
Types ¶
type Entity ¶
type Entity struct {
// ID of the entity
ID EntityID `json:"id,omitempty"`
// IP Address of this entity
IPAddress string `json:"ip_address"`
// Services is a List of names of services this entity is a part of.
// We store "well-known-labels" (identifying a service) in a separate
// fields for easier access. Note: we could store `[]agent_core/services/ServiceID`
// here directly, but right now it'd cause cyclic dependency.
Services []string `json:"services"`
// EntityName is the name of this entity
EntityName string `json:"name"`
}
Entity represents a pod, vm, etc.
Entities can be created with NewEntity.
type EntityCache ¶
EntityCache maps IP addresses and Entity names to entities.
func NewEntityCache ¶
func NewEntityCache() *EntityCache
NewEntityCache creates a new, empty EntityCache.
func ProvideEntityCache ¶
func ProvideEntityCache(in FxIn) (*EntityCache, error)
ProvideEntityCache creates Entity Cache.
func (*EntityCache) Clear ¶
func (c *EntityCache) Clear()
Clear removes all entities from the cache.
func (*EntityCache) DumpHandler ¶
func (c *EntityCache) DumpHandler(w http.ResponseWriter, req *http.Request)
DumpHandler is used to return entity cache data in JSON format.
func (*EntityCache) GetByIP ¶
func (c *EntityCache) GetByIP(entityIP string) *Entity
GetByIP retrieves entity with a given IP address.
func (*EntityCache) GetByName ¶
func (c *EntityCache) GetByName(entityName string) *Entity
GetByName retrieves entity with a given name.
func (*EntityCache) Put ¶
func (c *EntityCache) Put(entity *Entity)
Put maps given IP address and name to the entity it currently represents.
func (*EntityCache) Remove ¶
func (c *EntityCache) Remove(entity *Entity) bool
Remove removes entity from the cache and returns `true` if any of IP address or name mapping exists. If no such entity was found, returns `false`.
func (*EntityCache) Services ¶
func (c *EntityCache) Services() *entitycachev1.EntityCache
Services returns a list of services based on entities in cache.
Each service is identified by 2 values: - agent group - service name
This shouldn't happen in real world, but entities which have multiple values for an agent group is ignored. Entities which have multiple values for service name will create one service for each of them.
type FxIn ¶
type FxIn struct {
fx.In
Lifecycle fx.Lifecycle
Router *mux.Router
EntityTrackers notifiers.Trackers `name:"entity_trackers"`
}
FxIn are the parameters for ProvideEntityCache.
type ServiceKey ¶
type ServiceKey struct {
Name string `json:"name"`
}
ServiceKey holds key for service.