models

package
v0.0.0-...-9022b49 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRevisionIsLocal  = errors.New("revision archive is in local")
	ErrPackageNotExist  = errors.New("package does not exist")
	ErrRevisionNotExist = errors.New("revision does not exist")
)
View Source
var (
	ErrBlockRuleNotExist = errors.New("Block rule does not exist")
)

Functions

func AddDownloader

func AddDownloader(remoteAddr string) error

AddDownloader adds new downloader if it's not exist.

func BlockPackage

func BlockPackage(importPath, note string) (keys []string, err error)

BlockPackage blocks given package.

func DeleteBlockRule

func DeleteBlockRule(id int64) error

DeleteBlockRule deletes a block rule.

func DeleteRevisionById

func DeleteRevisionById(revId int64) error

DeleteRevisionById delete revision by given ID.

func IncreasePackageDownloadCount

func IncreasePackageDownloadCount(importPath string) error

IncreasePackageDownloadCount increase package download count by 1.

func IsPackageBlocked

func IsPackageBlocked(path string) (bool, error, error)

IsPackageBlocked checks if a package is blocked.

func NewBlockRule

func NewBlockRule(r *BlockRule) error

NewBlockRule creates new block rule.

func Ping

func Ping() error

func RunBlockRule

func RunBlockRule(id int64) (count int64, keys []string, err error)

RunBlockRule applies given block rule to all packages.

func UnblockPackage

func UnblockPackage(id int64) error

func UpdateRevision

func UpdateRevision(rev *Revision) error

UpdateRevision updates revision information.

Types

type Block

type Block struct {
	ID         int64  `xorm:"pk autoincr"`
	ImportPath string `xorm:"UNIQUE"`
	Note       string
}

Block represents information of a blocked package.

func ListBlockedPackages

func ListBlockedPackages(offset int) ([]*Block, error)

ListBlockedPackages returns a list of block rules with given offset.

type BlockError

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

BlockError represents a block error which contains block note.

func (*BlockError) Error

func (e *BlockError) Error() string

type BlockRule

type BlockRule struct {
	ID   int64  `xorm:"pk autoincr"`
	Rule string `xorm:"UNIQUE"`
	Note string
}

BlockRule represents a rule for blocking packages.

func GetBlockRuleByID

func GetBlockRuleByID(id int64) (*BlockRule, error)

GetBlockRuleByID returns a block rule by given ID.

func ListBlockRules

func ListBlockRules(offset int) ([]*BlockRule, error)

ListBlockRules returns a list of block rules with given offset.

type DownloadStats

type DownloadStats struct {
	NumTotalDownload int64
}

type Downloader

type Downloader struct {
	ID         int64  `xorm:"pk autoincr"`
	RemoteAddr string `xorm:"UNIQUE"`
}

Downloader represents a package download IP.

type Package

type Package struct {
	ID             int64  `xorm:"pk autoincr"`
	ImportPath     string `xorm:"UNIQUE"`
	Description    string
	Homepage       string
	Issues         string
	DownloadCount  int64
	RecentDownload int64
	IsValidated    bool      `xorm:"DEFAULT 0"`
	Created        time.Time `xorm:"CREATED"`
}

Package represents a Go package.

func GetPakcageByID

func GetPakcageByID(pkgID int64) (*Package, error)

GetPakcageByID returns a package by given ID.

func GetPakcageByPath

func GetPakcageByPath(importPath string) (*Package, error)

GetPakcageByPath returns a package by given import path.

func NewPackage

func NewPackage(importPath string) (*Package, error)

NewPackage creates

func SearchPackages

func SearchPackages(keys string) ([]*Package, error)

SearchPackages searchs packages by given keyword.

func (*Package) GetRevisions

func (pkg *Package) GetRevisions() ([]*Revision, error)

type Revision

type Revision struct {
	ID       int64    `xorm:"pk autoincr"`
	PkgID    int64    `xorm:"UNIQUE(s)"`
	Pkg      *Package `xorm:"-"`
	Revision string   `xorm:"UNIQUE(s)"`
	Storage
	Size    int64
	Updated time.Time `xorm:"UPDATED"`
}

Revision represents a revision of a Go package.

func CheckPkg

func CheckPkg(importPath, rev string) (*Revision, error)

CheckPkg checks if versioned package is in records, and download it when needed.

func GetLocalRevisions

func GetLocalRevisions() ([]*Revision, error)

GetLocalRevisions returns all revisions that archives are saved locally.

func GetRevision

func GetRevision(pkgID int64, rev string) (*Revision, error)

GetRevision returns revision by given pakcage ID and revision.

func GetRevisionsByPkgId

func GetRevisionsByPkgId(pkgId int64) ([]*Revision, error)

GetRevisionsByPkgId returns a list of revisions of given package ID.

func (*Revision) GetPackage

func (r *Revision) GetPackage() (err error)

func (*Revision) KeyName

func (r *Revision) KeyName() (string, error)

KeyName returns QiNiu key name.

type Stats

type Stats struct {
	NumPackages, NumDownloaders int64
	DownloadStats
	TrendingPackages, NewPackages, PopularPackages []*Package
}
var Statistic Stats

type Storage

type Storage int
const (
	LOCAL Storage = iota
)

Jump to

Keyboard shortcuts

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