Documentation
¶
Overview ¶
Package crawl executes bounded batches from the durable crawl frontier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frontier ¶
type Frontier interface {
LeaseFrontierItems(ctx context.Context, worker string, now time.Time, leaseDuration time.Duration, limit, budget int) ([]corpus.FrontierItem, error)
ReleaseFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
CompleteFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
RetryFrontierItem(ctx context.Context, id int64, worker, message string, earliestRunAt, now time.Time) error
FailFrontierItem(ctx context.Context, id int64, worker, failureKind, message string, now time.Time) error
}
Frontier is the durable lease boundary required by a Worker.
type Handler ¶
type Handler interface {
Handle(context.Context, corpus.FrontierItem) error
}
Handler hydrates one leased frontier item. It must respect ctx and return only after all writes for the item are durable.
type HandlerFunc ¶
type HandlerFunc func(context.Context, corpus.FrontierItem) error
HandlerFunc adapts a function to Handler.
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(ctx context.Context, item corpus.FrontierItem) error
type TerminalError ¶
TerminalError tells the worker that retrying an item cannot succeed without a source-state change.
func (*TerminalError) Error ¶
func (e *TerminalError) Error() string
func (*TerminalError) Unwrap ¶
func (e *TerminalError) Unwrap() error
type Worker ¶
type Worker struct {
Frontier Frontier
Handler Handler
ID string
BatchSize int
Budget int
LeaseDuration time.Duration
HandlerTimeout time.Duration
Backoff time.Duration
Now func() time.Time
Classify func(error, corpus.FrontierItem, time.Time) Decision
}
Worker leases and executes one bounded batch at a time.
Click to show internal directories.
Click to hide internal directories.