entities

package
v1.5.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module sets up Entities with Fx.

func RegisterEntitiesService

func RegisterEntitiesService(server *grpc.Server, cache *Entities, registry *rpc.HandlerRegistry) error

RegisterEntitiesService registers a service for entity cache.

Types

type Entities

type Entities struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Entities maps IP addresses and Entity names to entities.

func NewEntities

func NewEntities() *Entities

NewEntities creates a new, empty Entities.

func (*Entities) Clear

func (c *Entities) Clear()

Clear removes all entities from the cache.

func (*Entities) GetByIP

func (c *Entities) GetByIP(entityIP string) (*entitiesv1.Entity, error)

GetByIP retrieves entity with a given IP address.

func (*Entities) GetByName

func (c *Entities) GetByName(entityName string) (*entitiesv1.Entity, error)

GetByName retrieves entity with a given name.

func (*Entities) GetEntities

func (c *Entities) GetEntities() *entitiesv1.Entities

GetEntities returns *entitiesv1.EntitiyCache entities.

func (*Entities) Put

func (c *Entities) Put(entity *entitiesv1.Entity)

Put maps given IP address and name to the entity it currently represents.

func (*Entities) Remove

func (c *Entities) Remove(entity *entitiesv1.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`.

type EntitiesService

type EntitiesService struct {
	entitiesv1.UnimplementedEntitiesServiceServer
	// contains filtered or unexported fields
}

EntitiesService is the implementation of entitiesv1.EntitiesService interface.

func (*EntitiesService) GetEntities

func (c *EntitiesService) GetEntities(ctx context.Context, _ *emptypb.Empty) (*entitiesv1.Entities, error)

GetEntities returns *entitiesv1.Entities which contains mappings of ip address to entity and entity name to entity.

func (*EntitiesService) GetEntityByIPAddress

GetEntityByIPAddress returns an entity by IP address.

func (*EntitiesService) GetEntityByName

GetEntityByName returns an entity by name.

func (*EntitiesService) ListDiscoveryEntities added in v0.27.0

ListDiscoveryEntities lists currently discovered entities by IP address.

func (*EntitiesService) ListDiscoveryEntity added in v0.27.0

ListDiscoveryEntity returns an entity by IP address or name.

type EntityTrackers

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

EntityTrackers allows to register a service discovery for entity cache

Intended to be used during FX initialization.

func (*EntityTrackers) HasDiscovery

func (et *EntityTrackers) HasDiscovery() bool

HasDiscovery returns whether RegisterServiceDiscovery was called before.

func (*EntityTrackers) RegisterServiceDiscovery

func (et *EntityTrackers) RegisterServiceDiscovery(name string) notifiers.EventWriter

RegisterServiceDiscovery registers service discovery for entity cache and returns an EventWriter to push discovery events into.

Keys passed to EventWriter should not be prefixed.

Should be called at FX provide/invoke stage.

func (*EntityTrackers) Watcher

func (et *EntityTrackers) Watcher() notifiers.Watcher

Watcher returns watcher that watches all events from registered service discoveries.

type FxIn

type FxIn struct {
	fx.In
	Lifecycle      fx.Lifecycle
	EntityTrackers notifiers.Trackers `name:"entity_trackers_private"`
}

FxIn are the parameters for ProvideEntities.

Jump to

Keyboard shortcuts

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