entitycache

package
v0.21.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module added in v0.1.2

func Module() fx.Option

Module sets up EntityCache with Fx.

func RegisterEntityCacheService added in v0.1.2

func RegisterEntityCacheService(server *grpc.Server, cache *EntityCache)

RegisterEntityCacheService registers a service for entity cache.

Types

type EntityCache

type EntityCache struct {
	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) (*entitycachev1.Entity, error)

GetByIP retrieves entity with a given IP address.

func (*EntityCache) GetByName

func (c *EntityCache) GetByName(entityName string) (*entitycachev1.Entity, error)

GetByName retrieves entity with a given name.

func (*EntityCache) GetEntities added in v0.2.1

func (c *EntityCache) GetEntities() *entitycachev1.EntityCache

GetEntities returns *entitycachev1.EntitiyCache entities.

func (*EntityCache) Put

func (c *EntityCache) Put(entity *entitycachev1.Entity)

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

func (*EntityCache) Remove

func (c *EntityCache) Remove(entity *entitycachev1.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 EntityCacheService added in v0.2.1

type EntityCacheService struct {
	entitycachev1.UnimplementedEntityCacheServiceServer
	// contains filtered or unexported fields
}

EntityCacheService is the implementation of entitycachev1.EntityCacheService interface.

func (*EntityCacheService) GetEntityByIPAddress added in v0.2.1

GetEntityByIPAddress returns an entity by IP address.

func (*EntityCacheService) GetEntityByName added in v0.2.1

GetEntityByName returns an entity by name.

func (*EntityCacheService) GetEntityCache added in v0.2.1

GetEntityCache returns *entitycachev1.EntityCache which contains mappings of ip address to entity and entity name to entity.

type EntityTrackers added in v0.13.0

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 added in v0.13.0

func (et *EntityTrackers) HasDiscovery() bool

HasDiscovery returns whether RegisterServiceDiscovery was called before.

func (*EntityTrackers) RegisterServiceDiscovery added in v0.13.0

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 shouldn't be prefixed.

Should be called at FX provide/invoke stage.

func (*EntityTrackers) Watcher added in v0.13.0

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 ProvideEntityCache.

Jump to

Keyboard shortcuts

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