dao

package
v0.0.0-...-cfab22a Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2016 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleTable = "crawl_rules"
	TaskTable = "crawl_tasks"
)

Variables

View Source
var (
	ErrNotEqual = errors.New("not equal!")
	ErrNoTasks  = errors.New("no tasks!")
)

Functions

This section is empty.

Types

type RuleStatus

type RuleStatus int32
const (
	RULE_PAUSE RuleStatus = -1 + iota
	RULE_NORMAL
	RULE_ADDED
)

type TaskDao

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

func InitTaskDao

func InitTaskDao(db *sqlx.DB) *TaskDao

func (*TaskDao) AddNewTasks

func (this *TaskDao) AddNewTasks(tasks []types.CrawlTask) (int64, []sql.Result, error)

func (*TaskDao) ConvertRuleToTask

func (this *TaskDao) ConvertRuleToTask(rule types.CrawlRule) types.CrawlTask

规则转为任务

func (*TaskDao) GetWaitRules

func (this *TaskDao) GetWaitRules() ([]types.CrawlRule, error)

从规则库读取下一批需调度的规则

func (*TaskDao) GetWaitingTasks

func (this *TaskDao) GetWaitingTasks() ([]types.CrawlTask, error)

选取status为0, 或status=2且调度时间已到的任务

func (*TaskDao) SetTasksStatus

func (this *TaskDao) SetTasksStatus(tasks []types.CrawlTask, status TaskStatus) (int64, error)

设置任务状态

func (*TaskDao) UpdateRules

func (this *TaskDao) UpdateRules(rules []types.CrawlRule, taskAddedResults []sql.Result) (int64, error)

根据任务添加结果,修改rule的状态

type TaskStatus

type TaskStatus int32
const (
	TASK_CANCELED TaskStatus = -1 + iota
	TASK_WAITING
	TASK_CRAWLING
	TASK_FINISH
	TASK_FAILED
)

Jump to

Keyboard shortcuts

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