model

package
v0.0.0-...-fce466e Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// URLTaskStatusInit 任务状态初始值, 0
	URLTaskStatusInit = iota
	// URLTaskStatusPending 从队列中取出, 未出结果时的状态.
	URLTaskStatusPending
	// URLTaskStatusSuccess 任务状态成功, 2
	URLTaskStatusSuccess
	// URLTaskStatusFailed 任务状态失败(404), 3
	URLTaskStatusFailed
)
View Source
const (
	URLTypePage int = iota
	URLTypeAsset
)

Variables

This section is empty.

Functions

func AddOrUpdateURLRecord

func AddOrUpdateURLRecord(db *gorm.DB, task *URLRecord) (err error)

AddOrUpdateURLRecord 任务入队列时添加URLRecord新记录(如果已存在则更新failed_times和status字段)

func GetDB

func GetDB(dbPath string) (db *gorm.DB, err error)

GetDB 获取数据库链接

func UpdateURLRecordStatus

func UpdateURLRecordStatus(db *gorm.DB, url string, status int) (err error)

UpdateURLRecordStatus 更新url任务记录状态

Types

type URLRecord

type URLRecord struct {
	gorm.Model
	URL         string `gorm:"unique, not null"`
	Refer       string
	Depth       int
	URLType     int
	FailedTimes int
	Status      int `gorm:"default 0"`
}

URLRecord 任务记录表

func QueryUnfinishedAssetTasks

func QueryUnfinishedAssetTasks(db *gorm.DB) (tasks []*URLRecord, err error)

QueryUnfinishedAssetTasks ...

func QueryUnfinishedPageTasks

func QueryUnfinishedPageTasks(db *gorm.DB) (tasks []*URLRecord, err error)

QueryUnfinishedPageTasks ...

Jump to

Keyboard shortcuts

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