Documentation
¶
Index ¶
- Variables
- type BunRepository
- func (r *BunRepository) Delete(ctx context.Context, name string) error
- func (r *BunRepository) Get(ctx context.Context, name string) (*storage.Profile, error)
- func (r *BunRepository) List(ctx context.Context) ([]storage.Profile, error)
- func (r *BunRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
- func (r *BunRepository) Upsert(ctx context.Context, profile storage.Profile) (*storage.Profile, error)
- type ChangeEvent
- type ChangeType
- type MemoryRepository
- func (r *MemoryRepository) Delete(_ context.Context, name string) error
- func (r *MemoryRepository) Get(_ context.Context, name string) (*storage.Profile, error)
- func (r *MemoryRepository) List(context.Context) ([]storage.Profile, error)
- func (r *MemoryRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
- func (r *MemoryRepository) Upsert(_ context.Context, profile storage.Profile) (*storage.Profile, error)
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ErrProfileNameRequired = errors.New("storageconfig: profile name is required")
ErrProfileNameRequired indicates that profile operations require a non-empty name.
var ErrProfileNotFound = errors.New("storageconfig: profile not found")
ErrProfileNotFound indicates that a requested storage profile does not exist.
Functions ¶
This section is empty.
Types ¶
type BunRepository ¶
type BunRepository struct {
// contains filtered or unexported fields
}
BunRepository persists profiles using a Bun-backed database.
func NewBunRepository ¶
func NewBunRepository(db *bun.DB) *BunRepository
NewBunRepository constructs a Bun-backed repository.
func (*BunRepository) Delete ¶
func (r *BunRepository) Delete(ctx context.Context, name string) error
Delete removes a profile by name.
func (*BunRepository) Subscribe ¶
func (r *BunRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
Subscribe delivers change events until the context is cancelled.
type ChangeEvent ¶
type ChangeEvent struct {
Type ChangeType
Profile storage.Profile
}
ChangeEvent reports profile mutations to interested subscribers.
type ChangeType ¶
type ChangeType string
ChangeType enumerates storage profile change events.
const ( // ChangeCreated indicates a new profile was persisted. ChangeCreated ChangeType = "created" // ChangeUpdated indicates an existing profile was modified. ChangeUpdated ChangeType = "updated" // ChangeDeleted indicates a profile was removed. ChangeDeleted ChangeType = "deleted" )
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository stores profiles in-memory for tests and lightweight deployments.
func NewMemoryRepository ¶
func NewMemoryRepository() *MemoryRepository
NewMemoryRepository constructs an empty in-memory repository.
func (*MemoryRepository) Delete ¶
func (r *MemoryRepository) Delete(_ context.Context, name string) error
Delete removes a profile by name.
func (*MemoryRepository) Subscribe ¶
func (r *MemoryRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
Subscribe delivers change events until the context is cancelled.
type Repository ¶
type Repository interface {
List(ctx context.Context) ([]storage.Profile, error)
Get(ctx context.Context, name string) (*storage.Profile, error)
Upsert(ctx context.Context, profile storage.Profile) (*storage.Profile, error)
Delete(ctx context.Context, name string) error
Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
}
Repository exposes persistence operations for runtime storage profiles.