package database
import "git.sr.ht/~sircmpwn/gddo/internal/database"
Package database manages the storage of documentation.
Index ¶
- type Database
- func New(serverURI string) (*Database, error)
- func (db *Database) Directories(ctx context.Context, platform, modulePath, version, importPath string) ([]Synopsis, error)
- func (db *Database) HasPackage(ctx context.Context, platform, importPath, version string) (bool, error)
- func (db *Database) IsBlocked(ctx context.Context, importPath string) (bool, error)
- func (db *Database) Modules(ctx context.Context) (int64, error)
- func (db *Database) Oldest(ctx context.Context) (string, time.Time, error)
- func (db *Database) Package(ctx context.Context, platform, importPath, version string) (*Package, error)
- func (db *Database) Project(ctx context.Context, modulePath string) (*autodiscovery.Project, error)
- func (db *Database) ProjectUpdated(ctx context.Context, modulePath string) (time.Time, error)
- func (db *Database) PutDirectory(tx *sql.Tx, platform string, mod *internal.Module, importPath string, errorMsg string) error
- func (db *Database) PutModule(ctx context.Context, mod *internal.Module) error
- func (db *Database) PutPackage(tx *sql.Tx, platform string, mod *internal.Module, pkg *doc.Package, source []byte) error
- func (db *Database) PutProject(ctx context.Context, modulePath string, project *autodiscovery.Project) error
- func (db *Database) RegisterMetrics(r prometheus.Registerer) error
- func (db *Database) Search(ctx context.Context, platform, query string) ([]Synopsis, error)
- func (db *Database) Synopses(ctx context.Context, platform string, importPaths []string) ([]Synopsis, error)
- func (db *Database) TouchModule(ctx context.Context, modulePath string) error
- func (db *Database) WithTx(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error) error
- type Package
- type Synopsis
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database stores package documentation.
func New ¶
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 ¶
IsBlocked returns whether the package is blocked or belongs to a blocked domain/repo.
func (*Database) Modules ¶
Modules returns the number of modules in the database.
func (*Database) Oldest ¶
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 ¶
Project returns information about the project associated with the given module. It may return nil if no project exists.
func (*Database) ProjectUpdated ¶
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 ¶
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 ¶
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 ¶
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 ¶
Package contains package-level information and source code.
func (*Package) Decode ¶
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 ¶
Synopsis is a shorthand version of a package useful for package listings.
Source Files ¶
- Version
- v0.0.0-20240124133021-55358d4d592d (latest)
- Published
- Jan 24, 2024
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 2 days ago –
Tools for package owners.