Documentation
¶
Overview ¶
Package genericstore defines a generic object store that satisfies a redundant use-case in the tagger component implementation. The implementation of the tagger component requires storing objects indexed by keys. Keys are in the form of `{prefix}://{id}`.
Index ¶
- type ObjectStore
- func (os *ObjectStore[T]) ForEach(filter *types.Filter, apply types.ApplyFunc[T])
- func (os *ObjectStore[T]) Get(entityID types.EntityID) (object T, found bool)
- func (os *ObjectStore[T]) ListObjects(filter *types.Filter) []T
- func (os *ObjectStore[T]) Set(entityID types.EntityID, object T)
- func (os *ObjectStore[T]) Size() int
- func (os *ObjectStore[T]) Unset(entityID types.EntityID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObjectStore ¶ added in v0.74.0
type ObjectStore[T any] struct { // contains filtered or unexported fields }
ObjectStore is a generic store that can store objects indexed by keys.
func NewObjectStore ¶
func NewObjectStore[T any]() *ObjectStore[T]
NewObjectStore creates a new ObjectStore.
func (*ObjectStore[T]) ForEach ¶ added in v0.74.0
func (os *ObjectStore[T]) ForEach(filter *types.Filter, apply types.ApplyFunc[T])
ForEach applies the provided function to each object in the store matching the filter.
func (*ObjectStore[T]) Get ¶ added in v0.74.0
func (os *ObjectStore[T]) Get(entityID types.EntityID) (object T, found bool)
Get returns the object with the specified entity ID if it exists in the store.
func (*ObjectStore[T]) ListObjects ¶ added in v0.74.0
func (os *ObjectStore[T]) ListObjects(filter *types.Filter) []T
ListObjects returns every object in the store matching the provided filter.
func (*ObjectStore[T]) Set ¶ added in v0.74.0
func (os *ObjectStore[T]) Set(entityID types.EntityID, object T)
Set stores the provided object under the specified entity ID.
func (*ObjectStore[T]) Size ¶ added in v0.74.0
func (os *ObjectStore[T]) Size() int
Size returns the total number of objects in the store.
func (*ObjectStore[T]) Unset ¶ added in v0.74.0
func (os *ObjectStore[T]) Unset(entityID types.EntityID)
Unset removes the object associated with the specified entity ID.