repository

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package repository wraps shared components to work with repositories

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPatchQuery

func NewPatchQuery(opts ...PatchOption) *patchQuery

func WithLockingCtx

func WithLockingCtx(ctx context.Context, lockLevel LockLevel, lockModes ...LockMode) context.Context

WithLockingCtx sets the lock context with the provided lock level and modes.

Types

type Creator

type Creator[R resource.Resource] interface {
	Create(context.Context, R) (R, error)
}

type CreatorBatch

type CreatorBatch[R resource.Resource] interface {
	CreateBatch(context.Context, []R) ([]R, error)
}

type DeleteType

type DeleteType int
const (
	DeleteTypeSoft DeleteType = iota
	DeleteTypeHard
)

type Deleter

type Deleter interface {
	Delete(ctx context.Context, delType DeleteType, opts ...search.Option) error
}

type Getter

type Getter[R resource.Resource] interface {
	Get(ctx context.Context, opts ...search.Option) (R, error)
}

type Lister

type Lister[R resource.Resource] interface {
	List(ctx context.Context, opts ...search.Option) (resource.ListResponse[R], error)
}

type Lock

type Lock interface {
	Modes() []LockMode
	Level() LockLevel
	Contains(mode LockMode) bool
}

Lock defines the interface for locking mechanisms.

func LockFromCtx

func LockFromCtx(ctx context.Context) Lock

LockFromCtx retrieves the lock from the context.

type LockLevel

type LockLevel string
const (
	LockLevelRow LockLevel = "ROW"
)

type LockMode

type LockMode string
const (
	LockModeExclusive LockMode = "EXCLUSIVE"
	LockModeShare     LockMode = "SHARE"
)

type PatchOption

type PatchOption func(pq *patchQuery)

func PatchField

func PatchField(name string, value any) PatchOption

func PatchSearchOpts

func PatchSearchOpts(opts ...search.Option) PatchOption

func WithPatchFields

func WithPatchFields(patchFields map[string]any) PatchOption

func WithPatchQuery

func WithPatchQuery(query PatchQuery) PatchOption

func WithPatchQueryOpts

func WithPatchQueryOpts(opts ...PatchOption) PatchOption

type PatchQuery

type PatchQuery interface {
	SearchOpts() []search.Option
	PatchFields() map[string]any
	FilterPatchFields(allow ...string) map[string]any
}

type Patcher

type Patcher[R resource.Resource] interface {
	Patch(context.Context, ...PatchOption) ([]R, error)
}

type Updater

type Updater[R resource.Resource] interface {
	Update(context.Context, R) (R, error)
}

Directories

Path Synopsis
Package repositorytest provides test helpers for the generic repository package
Package repositorytest provides test helpers for the generic repository package

Jump to

Keyboard shortcuts

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