gddo: github.com/golang/gddo/database Index | Files

package database

import "github.com/golang/gddo/database"

Package database manages storage for GoPkgDoc.

Index

Package Files

database.go index.go indexae.go stem.go stop.go

func PurgeIndex Uses

func PurgeIndex(c context.Context) error

PurgeIndex deletes all the packages from the search index. TODO(shantuo): wrap this with db and use db.RemoteClient to create the context.

type Database Uses

type Database struct {
    Pool interface {
        Get() redis.Conn
    }

    RemoteClient *remote_api.Client
}

func New Uses

func New(serverURI string, idleTimeout time.Duration, logConn bool, gaeEndpoint string) (*Database, error)

New creates a gddo database. serverURI, idleTimeout, and logConn configure the use of redis. gaeEndpoint is the target of the App Engine remoteapi endpoint.

func (*Database) AddBadCrawl Uses

func (db *Database) AddBadCrawl(path string) error

func (*Database) AddNewCrawl Uses

func (db *Database) AddNewCrawl(importPath string) error

func (*Database) AllPackages Uses

func (db *Database) AllPackages() ([]Package, error)

func (*Database) Block Uses

func (db *Database) Block(root string) error

Block puts a domain, repo or package into the block set, removes all the packages under it from the database and prevents future crawling from it.

func (*Database) BumpCrawl Uses

func (db *Database) BumpCrawl(projectRoot string) error

func (*Database) CheckHealth Uses

func (db *Database) CheckHealth() error

func (*Database) Delete Uses

func (db *Database) Delete(ctx context.Context, path string) error

Delete deletes the documentation for the given import path.

func (*Database) DeleteIndex Uses

func (db *Database) DeleteIndex(ctx context.Context, id string) error

DeleteIndex deletes a package from App Engine search index. ID is the package ID in the database. It is no-op when running locally without setting up remote_api.

func (*Database) Do Uses

func (db *Database) Do(f func(*PackageInfo) error) error

Do executes function f for each document in the database.

func (*Database) Exists Uses

func (db *Database) Exists(path string) (bool, error)

Exists returns true if package with import path exists in the database.

func (*Database) Get Uses

func (db *Database) Get(ctx context.Context, path string) (*doc.Package, []Package, time.Time, error)

Get gets the package documentation and sub-directories for the the given import path.

func (*Database) GetDoc Uses

func (db *Database) GetDoc(ctx context.Context, path string) (*doc.Package, time.Time, error)

func (*Database) GetGob Uses

func (db *Database) GetGob(key string, value interface{}) error

func (*Database) GoIndex Uses

func (db *Database) GoIndex() ([]Package, error)

func (*Database) GoSubrepoIndex Uses

func (db *Database) GoSubrepoIndex() ([]Package, error)

func (*Database) ImportGraph Uses

func (db *Database) ImportGraph(pdoc *doc.Package, level DepLevel) ([]Package, [][2]int, error)

func (*Database) ImporterCount Uses

func (db *Database) ImporterCount(path string) (int, error)

func (*Database) Importers Uses

func (db *Database) Importers(path string) ([]Package, error)

func (*Database) IncrementCounter Uses

func (db *Database) IncrementCounter(key string, delta float64) (float64, error)

func (*Database) IncrementPopularScore Uses

func (db *Database) IncrementPopularScore(path string) error

func (*Database) Index Uses

func (db *Database) Index() ([]Package, error)

func (*Database) IsBlocked Uses

func (db *Database) IsBlocked(path string) (bool, error)

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

func (*Database) Packages Uses

func (db *Database) Packages(paths []string) ([]Package, error)

func (*Database) PopNewCrawl Uses

func (db *Database) PopNewCrawl() (string, bool, error)

func (*Database) Popular Uses

func (db *Database) Popular(count int) ([]Package, error)

func (*Database) PopularWithScores Uses

func (db *Database) PopularWithScores() ([]Package, error)

func (*Database) Project Uses

func (db *Database) Project(projectRoot string) ([]Package, error)

func (*Database) Put Uses

func (db *Database) Put(ctx context.Context, pdoc *doc.Package, nextCrawl time.Time, hide bool) error

Put adds the package documentation to the database.

func (*Database) PutGob Uses

func (db *Database) PutGob(key string, value interface{}) error

func (*Database) PutIndex Uses

func (db *Database) PutIndex(ctx context.Context, pdoc *doc.Package, id string, score float64, importCount int) error

PutIndex puts a package into App Engine search index. ID is the package ID in the database. It is no-op when running locally without setting up remote_api.

func (*Database) Query Uses

func (db *Database) Query(q string) ([]Package, error)

func (*Database) Reindex Uses

func (db *Database) Reindex(ctx context.Context) error

Reindex gets all the packages in database and put them into the search index. This will update the search index with the path, synopsis, score, import counts of all the packages in the database.

func (*Database) Search Uses

func (db *Database) Search(ctx context.Context, q string) ([]Package, error)

func (*Database) SetNextCrawl Uses

func (db *Database) SetNextCrawl(path string, t time.Time) error

SetNextCrawl sets the next crawl time for a package.

type DepLevel Uses

type DepLevel int

DepLevel specifies the level of depdenencies to show in an import graph.

const (
    ShowAllDeps      DepLevel = iota // show all dependencies
    HideStandardDeps                 // don't show dependencies of standard libraries
    HideStandardAll                  // don't show standard libraries at all
)

type Package Uses

type Package struct {
    Name        string  `json:"name,omitempty"`
    Path        string  `json:"path"`
    ImportCount int     `json:"import_count"`
    Synopsis    string  `json:"synopsis,omitempty"`
    Fork        bool    `json:"fork,omitempty"`
    Stars       int     `json:"stars,omitempty"`
    Score       float64 `json:"score,omitempty"`
}

Package represents the content of a package both for the search index and for the HTML template. It implements the search.FieldLoadSaver interface to customize the Rank function in the search index.

func (*Package) Load Uses

func (p *Package) Load(fields []search.Field, meta *search.DocumentMetadata) error

func (*Package) Save Uses

func (p *Package) Save() ([]search.Field, *search.DocumentMetadata, error)

type PackageInfo Uses

type PackageInfo struct {
    PDoc  *doc.Package
    Score float64
    Kind  string
    Size  int
}

Package database imports 26 packages (graph) and is imported by 110 packages. Updated 2019-08-19. Refresh now. Tools for package owners.