Documentation ¶
Index ¶
- func Merge(originalService, mergedService *entitycachev1.Service)
- func Module() fx.Option
- func RegisterEntityCacheService(server *grpc.Server, cache *EntityCache)
- func ServiceIDsFromEntity(entity *Entity) []services.ServiceID
- type Entity
- type EntityCache
- func (c *EntityCache) Clear()
- func (c *EntityCache) GetByIP(entityIP string) *Entity
- func (c *EntityCache) GetByName(entityName string) *Entity
- func (c *EntityCache) GetServicesList(ctx context.Context, _ *emptypb.Empty) (*entitycachev1.ServicesList, error)
- func (c *EntityCache) Put(entity *Entity)
- func (c *EntityCache) Remove(entity *Entity) bool
- func (c *EntityCache) Services() *entitycachev1.ServicesList
- 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 RegisterEntityCacheService ¶ added in v0.1.2
func RegisterEntityCacheService(server *grpc.Server, cache *EntityCache)
RegisterEntityCacheService registers a service for entity cache.
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 ¶
type EntityCache struct { entitycachev1.UnimplementedEntityCacheServiceServer sync.RWMutex // contains filtered or unexported fields }
EntityCache maps IP addresses and Entity names to entities.
func NewEntityCache ¶
func NewEntityCache() *EntityCache
NewEntityCache creates a new, empty EntityCache.
func (*EntityCache) Clear ¶
func (c *EntityCache) Clear()
Clear removes all entities from the cache.
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) GetServicesList ¶ added in v0.1.2
func (c *EntityCache) GetServicesList(ctx context.Context, _ *emptypb.Empty) (*entitycachev1.ServicesList, error)
GetServicesList returns a list of services based on entities in cache.
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.ServicesList
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 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.