entities

package
v2.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 16 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(in RegisterEntitiesServiceIn) 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 (e *Entities) Clear()

Clear removes all entities from the cache.

func (*Entities) GetByIP

func (e *Entities) GetByIP(entityIP string) (Entity, error)

GetByIP retrieves entity with a given IP address.

func (*Entities) GetByName

func (e *Entities) GetByName(entityName string) (Entity, error)

GetByName retrieves entity with a given name.

func (*Entities) GetEntities

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

GetEntities returns *entitiesv1.EntitiyCache entities.

func (*Entities) Put

func (e *Entities) Put(entity Entity)

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

func (*Entities) PutForTest added in v2.6.0

func (e *Entities) PutForTest(entity *entitiesv1.Entity)

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

func (*Entities) Remove

func (e *Entities) 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`.

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

ListDiscoveryEntities lists currently discovered entities by IP address.

func (*EntitiesService) ListDiscoveryEntity

ListDiscoveryEntity returns an entity by IP address or name.

type Entity added in v2.6.0

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

Entity is an immutable wrapper over *entitiesv1.Entity.

func NewEntity added in v2.6.0

func NewEntity(entity *entitiesv1.Entity) Entity

NewEntity creates a new immutable entity from the copy of given entity.

func NewEntityFromImmutable added in v2.6.0

func NewEntityFromImmutable(entity *entitiesv1.Entity) Entity

NewEntityFromImmutable creates a new immutable entity, assuming given entity is immutable.

This allows avoiding a copy compared to NewEntity.

func (Entity) Clone added in v2.6.0

func (e Entity) Clone() *entitiesv1.Entity

Clone returns a mutable copy of the entity.

func (Entity) IPAddress added in v2.6.0

func (e Entity) IPAddress() string

IPAddress returns the entity's IP address.

func (Entity) Name added in v2.6.0

func (e Entity) Name() string

Name returns the entity's name.

func (Entity) Namespace added in v2.6.0

func (e Entity) Namespace() string

Namespace returns the entity's namespace.

func (Entity) NodeName added in v2.6.0

func (e Entity) NodeName() string

NodeName returns the entity's node name.

func (Entity) Services added in v2.6.0

func (e Entity) Services() []string

Services returns list of services the entity belongs to.

The returned slice must not be modified.

func (Entity) UID added in v2.6.0

func (e Entity) UID() string

UID returns the entity's UID.

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.

type RegisterEntitiesServiceIn added in v2.16.0

type RegisterEntitiesServiceIn struct {
	fx.In
	Server   *grpc.Server `name:"default"`
	Cache    *Entities
	Registry *rpc.HandlerRegistry
}

RegisterEntitiesServiceIn bundles and annotates parameters.

Jump to

Keyboard shortcuts

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