repository

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc[Item interface{ GetName() string }] func(item Item) bool

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.

Jump to

Keyboard shortcuts

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