Documentation
¶
Index ¶
- Variables
- func ErrCreatingUserDataDirectory(dir string) error
- func ErrEmptySchema() error
- func ErrGetById(err error, id string) error
- func ErrMarshalingRegisteryAttempts(err error) error
- func ErrRegisteringEntity(failedMsg string, hostName string) error
- func ErrUnknownHost(err error) error
- func ErrUnknownHostInMap() error
- func ErrWritingRegisteryAttempts(err error) error
- func HostnameToPascalCase(input string) string
- type EntityCacheValue
- type MeshModelRegistrantData
- type Registry
- type RegistryEntityCache
- type RegistryManager
- func (rm *RegistryManager) Cleanup()
- func (rm *RegistryManager) GetEntities(f entity.Filter) ([]entity.Entity, int64, int, error)
- func (rm *RegistryManager) GetEntitiesMemoized(f entity.Filter, cache *RegistryEntityCache) ([]entity.Entity, int64, int, error)
- func (rm *RegistryManager) GetRegistrant(e entity.Entity) connection.Connection
- func (rm *RegistryManager) GetRegistrants(f *models.HostFilter) ([]models.MeshModelHostsWithEntitySummary, int64, error)
- func (rm *RegistryManager) RegisterEntity(h connection.Connection, en entity.Entity) (bool, bool, error)
- func (rm *RegistryManager) UpdateEntityStatus(ID string, status string, entityType string) error
Constants ¶
This section is empty.
Variables ¶
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 ErrEmptySchema ¶ added in v0.7.33
func ErrEmptySchema() error
func ErrGetById ¶ added in v0.7.50
func ErrMarshalingRegisteryAttempts ¶ added in v0.7.33
func ErrRegisteringEntity ¶ added in v0.7.33
func ErrUnknownHost ¶
func ErrUnknownHostInMap ¶ added in v0.7.33
func ErrUnknownHostInMap() error
func ErrWritingRegisteryAttempts ¶ added in v0.7.33
func HostnameToPascalCase ¶ added in v0.6.54
Types ¶
type EntityCacheValue ¶ added in v0.8.13
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 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
func (c *RegistryEntityCache) Get(f entity.Filter) (EntityCacheValue, bool)
Get retrieves a cached value
func (*RegistryEntityCache) Set ¶ added in v0.8.13
func (c *RegistryEntityCache) Set(f entity.Filter, value EntityCacheValue)
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 (*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
func (rm *RegistryManager) GetRegistrants(f *models.HostFilter) ([]models.MeshModelHostsWithEntitySummary, int64, error)
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