middleware

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRetryable = errors.New("not retryable")

ErrNotRetryable should be returned by the job to avoid retrying it.

Functions

func Retry added in v0.4.0

func Retry(retries uint) workers.Middleware

Retry is a job middleware that allows to retry a job if it returns an error.

If you consider that the error is not retryable you can either return nil or the custom "ErrNotRetryable".

func Wait

Wait will add a pause between calls to the next job. The pause affects only jobs between the same worker.

Types

type Counter

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

Counter count how many jobs have started and finished. Keep in mind that it's not protected against overflows.

func (*Counter) Failed added in v0.4.0

func (c *Counter) Failed() uint64

Running returns the number of failed jobs.

func (*Counter) Finished

func (c *Counter) Finished() uint64

Finished returns the number of jobs that have been finished.

func (*Counter) Running added in v0.2.0

func (c *Counter) Running() uint64

Running returns the number of jobs that are running now.

func (*Counter) Started

func (c *Counter) Started() uint64

Started returns the number of jobs that have been started.

func (*Counter) Wrap added in v0.3.0

func (c *Counter) Wrap(next workers.Job) workers.Job

Wrap wraps the job adding counters.

type Elapsed

type Elapsed struct {
	Counter
	// contains filtered or unexported fields
}

Elapsed is a job middleware that extends the simple counter and calculates the total time, average time and the last time spent doing the job.

func (*Elapsed) Average

func (e *Elapsed) Average() time.Duration

Average returns the average time that takes to run the job.

func (*Elapsed) Last

func (e *Elapsed) Last() time.Duration

Last returns the time spent executing the last job.

func (*Elapsed) Total

func (e *Elapsed) Total() time.Duration

Total returns the total time spent executing all the job across all the workers.

func (*Elapsed) Wrap added in v0.3.0

func (e *Elapsed) Wrap(next workers.Job) workers.Job

Wrap wraps the inner job to obtain job timing metrics.

Jump to

Keyboard shortcuts

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