database

package
v0.0.0-...-dfb07a6 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2016 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package database manages storage for GoPkgDoc.

Index

Constants

This section is empty.

Variables

View Source
var (
	RedisServer      = "redis://127.0.0.1:6379" // URL of Redis server
	RedisIdleTimeout = 250 * time.Second        // Close Redis connections after remaining idle for this duration.
	RedisLog         = false                    // Log database commands
	GAESearch        = false                    // Use GAE Search API in the search function.
)

Configuration variables (and default values of flags.

Functions

func PutIndex

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

PutIndex creates or updates a package entry in the search index. id identifies the document in the index. If pdoc is non-nil, PutIndex will update the package's name, path and synopsis supplied by pdoc. pdoc must be non-nil for a package's first call to PutIndex. PutIndex updates the Score to score, if non-negative.

Types

type Database

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

func New

func New() (*Database, error)

New creates a database configured from command line flags.

func (*Database) AddBadCrawl

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

func (*Database) AddNewCrawl

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

func (*Database) AllPackages

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

func (*Database) Block

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

func (*Database) BumpCrawl

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

func (*Database) Delete

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

Delete deletes the documentation for the given import path.

func (*Database) Do

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

Do executes function f for each document in the database.

func (*Database) Exists

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

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

func (*Database) Get

func (db *Database) Get(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

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

func (*Database) GetGob

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

func (*Database) GoIndex

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

func (*Database) GoSubrepoIndex

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

func (*Database) ImportGraph

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

func (*Database) ImporterCount

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

func (*Database) Importers

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

func (*Database) IncrementCounter

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

func (*Database) IncrementPopularScore

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

func (*Database) Index

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

func (*Database) IsBlocked

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

func (*Database) Packages

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

func (*Database) PopNewCrawl

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

func (*Database) Popular

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

func (*Database) PopularWithScores

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

func (*Database) Project

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

func (*Database) Put

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

Put adds the package documentation to the database.

func (*Database) PutGob

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

func (*Database) Query

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

func (*Database) SetNextCrawlEtag

func (db *Database) SetNextCrawlEtag(projectRoot string, etag string, t time.Time) error

SetNextCrawlEtag sets the next crawl time for all packages in the project with the given etag.

type DepLevel

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

type Package struct {
	Path     string `json:"path"`
	Synopsis string `json:"synopsis,omitempty"`
}
func Search(c context.Context, q string) ([]Package, error)

Search searches the packages index for a given query. A path-like query string will be passed in unchanged, whereas single words will be stemmed.

type PackageDocument

type PackageDocument struct {
	Name        search.Atom
	Path        string
	Synopsis    string
	Score       float64
	ImportCount float64
}

PackageDocument defines the data structure used to represent a package document in the search index.

type PackageInfo

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

Jump to

Keyboard shortcuts

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