registry

package
v0.8.17 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownHostCode                 = "meshkit-11255"
	ErrEmptySchemaCode                 = "meshkit-11256"
	ErrMarshalingRegisteryAttemptsCode = "meshkit-11257"
	ErrWritingRegisteryAttemptsCode    = "meshkit-11258"
	ErrRegisteringEntityCode           = "meshkit-11259"
	ErrUnknownHostInMapCode            = "meshkit-11260"
	ErrCreatingUserDataDirectoryCode   = "meshkit-11261"
	ErrGetByIdCode                     = "meshkit-11262"
)

Functions

func ErrCreatingUserDataDirectory added in v0.7.33

func ErrCreatingUserDataDirectory(dir string) error

func ErrEmptySchema added in v0.7.33

func ErrEmptySchema() error

func ErrGetById added in v0.7.50

func ErrGetById(err error, id string) error

func ErrMarshalingRegisteryAttempts added in v0.7.33

func ErrMarshalingRegisteryAttempts(err error) error

func ErrRegisteringEntity added in v0.7.33

func ErrRegisteringEntity(failedMsg string, hostName string) error

func ErrUnknownHost

func ErrUnknownHost(err error) error

func ErrUnknownHostInMap added in v0.7.33

func ErrUnknownHostInMap() error

func ErrWritingRegisteryAttempts added in v0.7.33

func ErrWritingRegisteryAttempts(err error) error

func HostnameToPascalCase added in v0.6.54

func HostnameToPascalCase(input string) string

Types

type EntityCacheValue added in v0.8.13

type EntityCacheValue struct {
	Entities []entity.Entity
	Count    int64
	Unique   int
	// contains filtered or unexported fields
}

type MeshModelRegistrantData

type MeshModelRegistrantData struct {
	Connection connection.Connection `json:"connection"`
	EntityType entity.EntityType     `json:"entityType"`
	Entity     []byte                `json:"entity"` //This will be type converted to appropriate entity on server based on passed entity type
}

MeshModelRegistrantData struct defines the body of the POST request that is sent to the capability registry (Meshery)

The body contains the 1. Host information 2. Entity type 3. Entity

type Registry

type Registry struct {
	ID           uuid.UUID
	RegistrantID uuid.UUID
	Entity       uuid.UUID
	Type         entity.EntityType
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type RegistryEntityCache added in v0.8.13

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

RegistryEntityCache is a thread-safe cache for storing entity query results.

This cache maps entity filters (`entity.Filter`) to their corresponding results (`EntityCacheValue`). It uses `sync.Map` for safe concurrent access, making it suitable for multi-goroutine environments.

The caller is responsible for managing the cache's lifecycle, including eviction and expiration if needed.

func (*RegistryEntityCache) Get added in v0.8.13

Get retrieves a cached value

func (*RegistryEntityCache) Set added in v0.8.13

Set stores a value in the cache

type RegistryManager

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

RegistryManager instance will expose methods for registry operations & sits between the database level operations and user facing API handlers.

func NewRegistryManager

func NewRegistryManager(db *database.Handler) (*RegistryManager, error)

NewRegistryManager initializes the registry manager by creating appropriate tables. Any new entities that are added to the registry should be migrated here into the database

func (*RegistryManager) Cleanup

func (rm *RegistryManager) Cleanup()

func (*RegistryManager) GetEntities

func (rm *RegistryManager) GetEntities(f entity.Filter) ([]entity.Entity, int64, int, error)

func (*RegistryManager) GetEntitiesMemoized added in v0.8.13

func (rm *RegistryManager) GetEntitiesMemoized(f entity.Filter, cache *RegistryEntityCache) ([]entity.Entity, int64, int, error)

GetEntitiesMemoized retrieves entities based on the provided filter `f`, using a concurrent-safe cache to optimize performance.

## Cache Behavior:

  • **Cache Hit**: If the requested entities are found in the `cache`, the function returns the cached result immediately, avoiding a redundant query.
  • **Cache Miss**: If the requested entities are *not* found in the cache, the function fetches them from the registry using `rm.GetEntities(f)`, stores the result in the `cache`, and returns the newly retrieved entities.

## Concurrency and Thread Safety: - The `cache` is implemented using `sync.Map`, ensuring **safe concurrent access** across multiple goroutines. - `sync.Map` is optimized for scenarios where **reads significantly outnumber writes**, making it well-suited for caching use cases.

## Ownership and Responsibility:

  • **RegistryManager (`rm`)**: Owns the logic for retrieving entities from the source when a cache miss occurs.
  • **Caller Ownership of Cache**: The caller is responsible for providing and managing the `cache` instance. This function does *not* handle cache eviction, expiration, or memory constraints—those concerns must be managed externally.

## Parameters: - `f entity.Filter`: The filter criteria used to retrieve entities. - `cache *RegistryEntityCache`: A pointer to a concurrent-safe cache (`sync.Map`) that stores previously retrieved entity results.

## Returns: - `[]entity.Entity`: The list of retrieved entities (either from cache or freshly fetched). - `int64`: The total count of entities matching the filter. - `int`: The number of unique entities found. - `error`: An error if the retrieval operation fails.

func (*RegistryManager) GetRegistrant

func (rm *RegistryManager) GetRegistrant(e entity.Entity) connection.Connection

func (*RegistryManager) GetRegistrants added in v0.6.73

to be removed

func (*RegistryManager) RegisterEntity

func (rm *RegistryManager) RegisterEntity(h connection.Connection, en entity.Entity) (bool, bool, error)

func (*RegistryManager) UpdateEntityStatus added in v0.7.14

func (rm *RegistryManager) UpdateEntityStatus(ID string, status string, entityType string) error

UpdateEntityStatus updates the ignore status of an entity based on the provided parameters. By default during models generation ignore is set to false

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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