db

package
v0.78.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package db provides a database to store information about packages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPackageNotFound is returned when a package is not found
	ErrPackageNotFound = errors.New("package not found")
)

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option is a function that sets an option on a PackagesDB

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout for opening the database

type Package

type Package struct {
	Name    string
	Version string

	InstallerVersion string
}

Package represents a package

type PackagesDB

type PackagesDB struct {
	// contains filtered or unexported fields
}

PackagesDB is a database that stores information about packages

func New

func New(ctx context.Context, dbPath string, opts ...Option) (*PackagesDB, error)

New creates a new PackagesDB. The context can be used to cancel the file lock acquisition if the database is held by another process, allowing the caller to abort instead of waiting for the bbolt timeout (or indefinitely if none is set).

func (*PackagesDB) Close

func (p *PackagesDB) Close() error

Close closes the database

func (*PackagesDB) DeletePackage

func (p *PackagesDB) DeletePackage(name string) error

DeletePackage deletes a package by name

func (*PackagesDB) GetPackage

func (p *PackagesDB) GetPackage(name string) (Package, error)

GetPackage returns a package by name

func (*PackagesDB) HasPackage

func (p *PackagesDB) HasPackage(name string) (bool, error)

HasPackage checks if a package exists

func (*PackagesDB) ListPackages

func (p *PackagesDB) ListPackages() ([]Package, error)

ListPackages returns a list of all packages

func (*PackagesDB) SetPackage

func (p *PackagesDB) SetPackage(pkg Package) error

SetPackage sets a package

Jump to

Keyboard shortcuts

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