store

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	DependentID string `json:"dependent_id" db:"dependent_id"`
	DependeeID  string `json:"dependee_id" db:"dependee_id"`
}

A Dependency represents a link between specific versions of 2 Go modules

type Logger added in v0.14.0

type Logger interface {
	Debug(string, ...any)
	Error(error, string, ...any)
}

type Module

type Module struct {
	ID          int32          `json:"id" db:"id"`
	Name        string         `json:"name,omitempty" db:"name"`
	Description sql.NullString `json:"description,omitempty" db:"description"`
}

A Module represents a particular Go module known by the system.

type ModuleVersionQuery added in v0.5.0

type ModuleVersionQuery struct {
	// a glob pattern specifying which module(s) should be returned
	ModuleFilter string
	// a glob pattern specifying which version(s) should be returned
	VersionFilter string
	// if true, the query will also return pre-release versions
	IncludePrerelease bool
	// if true, the query will only return the most current version
	LatestOnly bool

	PageToken string
	Count     int
}

ModuleVersionQuery encapsulates the available parameters for querying for module versions.

A zero value will return all stable versions for all modules.

type ModuleVersionQueryResult added in v0.5.0

type ModuleVersionQueryResult struct {
	Module, Version string
}

ModuleVersionQueryResult is represents a set of modules each having a list of versions

type PGOption

type PGOption func(*PostgresClient) error

PGOption defines a configuration option to be used when constructing the database connection.

func WithLog

func WithLog(l Logger) PGOption

WithLog returns a PGOption that attaches the provided debug logging callback function

type PostgresClient

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

PostgresClient performs store-related operations against a postgres backend database.

func NewPostgresClient

func NewPostgresClient(ctx context.Context, url string, opts ...PGOption) (*PostgresClient, error)

NewPostgresClient initializes a store client for interacting with a PostgreSQL backend. If it can not immediately reach the target database, an error is returned.

func (*PostgresClient) GetDependees

func (p *PostgresClient) GetDependees(ctx context.Context, id, version string, pageToken string, count int) ([]Version, string, error)

GetDependees retrieves all known module versions that the given module id and version pair depend on.

func (*PostgresClient) GetDependents

func (p *PostgresClient) GetDependents(ctx context.Context, id, version string, pageToken string, count int) ([]Version, string, error)

GetDependents retrieves all known module versions that depend on the given module id and version pair.

func (*PostgresClient) Ping added in v0.7.0

func (p *PostgresClient) Ping(ctx context.Context) error

Ping verifies that the database connection is available

func (*PostgresClient) QueryModuleVersions

func (p *PostgresClient) QueryModuleVersions(ctx context.Context, query ModuleVersionQuery) (results []ModuleVersionQueryResult, nextPageToken string, err error)

QueryModuleVersions returns a list of 0 or more module versions for the specified module, along with a paging token.

The pageToken argument, if provided, should be the return value from a prior call to this method with the same filter. It will be decoded to determine the next "page" of results. An invalid page token will result in an error being returned.

func (*PostgresClient) QueryModules

func (p *PostgresClient) QueryModules(ctx context.Context, nameFilter string, pageToken string, count int) ([]Module, string, error)

QueryModules returns a list of 0 to count modules that match the specified name filter (glob format), along with a paging token.

The pageToken argument, if provided, should be the return value from a prior call to this method with the same filter. It will be decoded to determine the next "page" of results. An invalid page token will result in an error being returned.

func (*PostgresClient) SaveModule

func (p *PostgresClient) SaveModule(ctx context.Context, name, description string, versions ...string) (err error)

SaveModule upserts module metadata. If there is an existing module with the provided name the description will be updated. Otherwise, a new module will be inserted.

func (*PostgresClient) SaveModuleDependencies

func (p *PostgresClient) SaveModuleDependencies(ctx context.Context, mod Version, deps ...Version) (err error)

SaveModuleDependencies writes the specified set of direct dependencies of mod to the database.

type Store

type Store interface {
	Ping(ctx context.Context) error

	SaveModule(ctx context.Context, name, description string, versions ...string) error
	SaveModuleDependencies(ctx context.Context, mod Version, deps ...Version) error

	QueryModules(ctx context.Context, nameFilter string, pageToken string, count int) ([]Module, string, error)
	QueryModuleVersions(ctx context.Context, query ModuleVersionQuery) (results []ModuleVersionQueryResult, nextPageToken string, err error)

	GetDependents(ctx context.Context, id, version string, pageToken string, count int) ([]Version, string, error)
	GetDependees(ctx context.Context, id, version string, pageToken string, count int) ([]Version, string, error)
}

Store defines the operations available on a Perseus data store

type Version

type Version struct {
	ID       int32  `json:"id" db:"id"`
	ModuleID string `json:"module_id" db:"module_id"`
	SemVer   string `json:"semver" db:"version"`
}

A Version represents a specific version of a Go module

Jump to

Keyboard shortcuts

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