persistence

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is the error returned if a resource cannot be found.
	ErrNotFound = errors.New("not found error")

	// ErrNotValid is the error returned if the data provided is invalid.
	ErrNotValid = errors.New("invalid data error")

	// ErrInternal is the error returned if an internal error occurred.
	ErrInternal = errors.New("internal error")
)

Functions

func WithTelemetry

func WithTelemetry(wrapped Service, tracer trace.Tracer) *wrapper

WithTelemetry enriches Service by adding instrumentation and context.

Types

type PackageFilter

type PackageFilter struct {
	Name       *string
	AIPID      *uuid.UUID
	LocationID *uuid.UUID
	Status     *enums.PackageStatus
	CreatedAt  *timerange.Range

	Sort
	Page
}

type PackageUpdater

type PackageUpdater func(*datatypes.Package) (*datatypes.Package, error)

type Page

type Page struct {
	// Limit is the maximum number of results per page.
	Limit int

	// Offset is the ordinal position, relative to the start of the unfiltered
	// set, of the first result of the page.
	Offset int

	// Total is the total number of search results before paging.
	Total int
}

Page represents a subset of results within a search result set.

func (*Page) Goa

func (p *Page) Goa() *goapackage.EnduroPage

type Service

type Service interface {
	// CreatePackage persists the given Package to the data store then updates
	// the Package from the data store, adding auto-generated data
	// (e.g. ID, CreatedAt).
	CreatePackage(context.Context, *datatypes.Package) error
	UpdatePackage(context.Context, int, PackageUpdater) (*datatypes.Package, error)
	ListPackages(context.Context, *PackageFilter) ([]*datatypes.Package, *Page, error)

	CreatePreservationAction(context.Context, *datatypes.PreservationAction) error

	CreatePreservationTask(context.Context, *datatypes.PreservationTask) error
	UpdatePreservationTask(ctx context.Context, id int, updater PresTaskUpdater) (*datatypes.PreservationTask, error)
}

type Sort

type Sort []SortColumn

Sort determines how the filtered results are sorted by specifying a slice of sort columns. The first SortColumn has the highest sort precedence, and the last SortColumn the lowest precedence.

func NewSort

func NewSort() Sort

NewSort returns a new sort instance.

func (Sort) AddCol

func (s Sort) AddCol(name string, desc bool) Sort

AddCol adds a SortColumn to a Sort then returns the updated Sort.

type SortColumn

type SortColumn struct {
	// Name of the column on which to sort the results.
	Name string

	// Desc is true if the sort order is descending.
	Desc bool
}

SortColumn specifies a column name on which to sort results, and the direction of the sort (ascending or descending).

Directories

Path Synopsis
ent
db
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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