entitycache

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: AGPL-3.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 FxIn

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

FxIn are the parameters for ProvideEntityCache.

Jump to

Keyboard shortcuts

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