job

package
v0.0.0-...-766fba4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JobQueue chan Job

JobQueue A buffered channel that we can send work requests on.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	MaxWorkers int
	WorkerPool chan chan Job
}

Dispatcher 工作池

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

NewDispatcher 创建新的工作池

func (*Dispatcher) Run

func (d *Dispatcher) Run()

Run Dispatcher.Run 工作池开始工作

type Job

type Job struct {
	Task Task
}

Job represents the job to be run

type Task

type Task interface {
	RunTask()
}

Task 任务接口

type TaskDemo

type TaskDemo struct {
	OpenID string
	Text   string
}

TaskDemo struct

func (*TaskDemo) RunTask

func (p *TaskDemo) RunTask()

RunTask 实现 Task.RunTask()

type TaskSpider

type TaskSpider struct {
	URL string
}

TaskSpider struct 采集任务

func (*TaskSpider) RunTask

func (t *TaskSpider) RunTask()

RunTask 实现 Task.RunTask()

type Worker

type Worker struct {
	WorkerPool chan chan Job
	JobChannel chan Job
	// contains filtered or unexported fields
}

Worker represents the worker that executes the job

func NewWorker

func NewWorker(workerPool chan chan Job) Worker

NewWorker new worker

func (Worker) Start

func (w Worker) Start()

Start method starts the run loop for the worker, listening for a quit channel in case we need to stop it

func (Worker) Stop

func (w Worker) Stop()

Stop signals the worker to stop listening for work requests.

Jump to

Keyboard shortcuts

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