store

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 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 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 PGOption

type PGOption func(*PostgresClient) error

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

func WithLog

func WithLog(fn func(string, ...any)) 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) QueryModuleVersions

func (p *PostgresClient) QueryModuleVersions(ctx context.Context, module string, pageToken string, count int) (results []Version, 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 {
	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, module string, pageToken string, count int) (results []Version, 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