database

package
v0.0.0-...-55358d4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package database manages the storage of documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database stores package documentation.

func New

func New(serverURI string) (*Database, error)

New creates a new database. serverURI is the postgres URI.

func (*Database) Directories

func (db *Database) Directories(ctx context.Context, platform, modulePath, version, importPath string) ([]Synopsis, error)

Directories returns the subdirectories for a given package.

func (*Database) HasPackage

func (db *Database) HasPackage(ctx context.Context, platform, importPath, version string) (bool, error)

HasPackage reports whether the given package is present in the database.

func (*Database) IsBlocked

func (db *Database) IsBlocked(ctx context.Context, importPath string) (bool, error)

IsBlocked returns whether the package is blocked or belongs to a blocked domain/repo.

func (*Database) Modules

func (db *Database) Modules(ctx context.Context) (int64, error)

Modules returns the number of modules in the database.

func (*Database) Oldest

func (db *Database) Oldest(ctx context.Context) (string, time.Time, error)

Oldest returns the module path of the oldest module in the database (i.e., the module with the smallest updated timestamp).

func (*Database) Package

func (db *Database) Package(ctx context.Context, platform, importPath, version string) (*Package, error)

Package returns information for the package with the given import path. It may return nil if no such package was found.

func (*Database) Project

func (db *Database) Project(ctx context.Context, modulePath string) (*autodiscovery.Project, error)

Project returns information about the project associated with the given module. It may return nil if no project exists.

func (*Database) ProjectUpdated

func (db *Database) ProjectUpdated(ctx context.Context, modulePath string) (time.Time, error)

ProjectUpdated returns the last time the project was updated. If no project exists, it returns the zero timestamp.

func (*Database) PutDirectory

func (db *Database) PutDirectory(tx *sql.Tx, platform string, mod *internal.Module, importPath string, errorMsg string) error

PutDirectory stores the directory in the database.

func (*Database) PutModule

func (db *Database) PutModule(ctx context.Context, mod *internal.Module) error

PutModule stores the module in the database.

func (*Database) PutPackage

func (db *Database) PutPackage(tx *sql.Tx, platform string, mod *internal.Module, pkg *doc.Package, source []byte) error

PutPackage stores the package in the database.

func (*Database) PutProject

func (db *Database) PutProject(ctx context.Context, modulePath string, project *autodiscovery.Project) error

PutProject puts project information in the database.

func (*Database) RegisterMetrics

func (db *Database) RegisterMetrics(r prometheus.Registerer) error

func (*Database) Search

func (db *Database) Search(ctx context.Context, platform, query string) ([]Synopsis, error)

Search performs a search with the provided query string.

func (*Database) Synopses

func (db *Database) Synopses(ctx context.Context, platform string, importPaths []string) ([]Synopsis, error)

Synopses returns a list of package synopses for the given import paths.

func (*Database) TouchModule

func (db *Database) TouchModule(ctx context.Context, modulePath string) error

TouchModule updates the module's updated timestamp. If the module does not exist, TouchModule does nothing.

func (*Database) WithTx

func (db *Database) WithTx(ctx context.Context, opts *sql.TxOptions,
	fn func(tx *sql.Tx) error) error

type Package

type Package struct {
	internal.Module
	Source []byte // encoded Go source files
	Error  string
}

Package contains package-level information and source code.

func (*Package) Decode

func (p *Package) Decode() (*godoc.Package, error)

Decode decodes a godoc.Package from the encoded Go source files in this package. It returns nil if there are no Go source files.

type Synopsis

type Synopsis struct {
	ImportPath string
	Synopsis   string
}

Synopsis is a shorthand version of a package useful for package listings.

Jump to

Keyboard shortcuts

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