Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc defines a predicate function for filtering repository items.
type InMemoryRepository ¶
type InMemoryRepository[Item interface{ GetName() string }] struct {
// contains filtered or unexported fields
}
InMemoryRepository is an in-memory implementation of Repository.
func NewInMemoryRepository ¶
func NewInMemoryRepository[Item interface{ GetName() string }]() *InMemoryRepository[Item]
NewInMemoryRepository creates a new in-memory repository.
func (*InMemoryRepository[Item]) Delete ¶
func (r *InMemoryRepository[Item]) Delete(item Item) error
Delete removes an item from the repository.
func (*InMemoryRepository[Item]) Get ¶
func (r *InMemoryRepository[Item]) Get(item Item) (Item, error)
Get retrieves an item by its name.
func (*InMemoryRepository[Item]) List ¶
func (r *InMemoryRepository[Item]) List(filter FilterFunc[Item]) ([]Item, error)
List returns all items matching the filter.
func (*InMemoryRepository[Item]) Store ¶
func (r *InMemoryRepository[Item]) Store(item Item) error
Store adds or updates an item in the repository.
type Repository ¶
type Repository[Item interface{ GetName() string }] interface {
Store(item Item) error
Get(item Item) (Item, error)
List(filter FilterFunc[Item]) ([]Item, error)
Delete(item Item) error
}
Repository is a generic interface for storing and retrieving items. Item must implement GetName() string.
Click to show internal directories.
Click to hide internal directories.