schedulers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicScheduler

type BasicScheduler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BasicScheduler is a basic Scheduler that implements the Scheduler interface.

func NewBasicScheduler

func NewBasicScheduler() *BasicScheduler

NewBasicScheduler returns a new BasicScheduler.

func (*BasicScheduler) Handle

Handle a spider.Spider and returns a new BasicSpiderScheduler associated with this spider.

func (*BasicScheduler) Start

func (bs *BasicScheduler) Start() error

Start starts the Scheduler. It will dispatch each spiders in their own watchers for each duplicated (goroutines).

type BasicSpiderScheduler

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

BasicSpiderScheduler represents a schedule configuration for a spider.

func NewBasicSpiderScheduler

func NewBasicSpiderScheduler() *BasicSpiderScheduler

NewBasicSpiderScheduler returns a new BasicSpiderScheduler

func (*BasicSpiderScheduler) After

After defines a delay between each goroutines

func (*BasicSpiderScheduler) Delay

func (b *BasicSpiderScheduler) Delay() time.Duration

Delay returns the delay between each goroutines

func (*BasicSpiderScheduler) Duplicate

func (b *BasicSpiderScheduler) Duplicate(numGoRoutines int64) spider.SpiderScheduler

Duplicate sets in how many goroutines the current spider will be duplicated.

func (*BasicSpiderScheduler) Every

Every sets a fixed duration representing when to spin.

func (*BasicSpiderScheduler) EveryFunc

Every sets a function that returns a duration representing when to spin.

func (*BasicSpiderScheduler) EveryRandom

func (b *BasicSpiderScheduler) EveryRandom(d, min, max time.Duration) spider.SpiderScheduler

Every sets a randomized duration representing when to spin. The second and third argument represents min and max duration for randomness. For exemple:

EveryRandom(2*time.Minute, 15*time.Second, 45*time.Second)

Will represent: 2 minutes + a random duration between 15 seconds and 45 seconds

func (*BasicSpiderScheduler) From

From defines when the scheduled spider has to start

func (*BasicSpiderScheduler) NextSpin

func (b *BasicSpiderScheduler) NextSpin() (time.Duration, bool)

NextSpin returns when a spider has to spin a web based on the provided schedule. The second argument is a boolean that indicates if it there is no more spins.

func (*BasicSpiderScheduler) NextSpinChan

func (b *BasicSpiderScheduler) NextSpinChan() (<-chan struct{}, <-chan struct{})

NextSpinChan returns two channels the first one is a spin channel representing when a spider have to spin a web and the second is a done channel representing when there is webs to be spun.

func (*BasicSpiderScheduler) NumGoroutine

func (b *BasicSpiderScheduler) NumGoroutine() int64

NumGoroutine returns the number of goroutines.

func (*BasicSpiderScheduler) To

To defines when the scheduled spider has to stop

Jump to

Keyboard shortcuts

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