unique

package
v0.1.3-0...-545a7b7 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDedupDuration = errors.New("work: unique duration should be > 0")
)

Functions

func Enqueuer

func Enqueuer(eopt *EnqueuerOptions) work.EnqueueMiddleware

Enqueuer uses UniqueFunc to ensure job uniqueness in a period.

func HandleFunc

func HandleFunc(f work.HandleFunc, hopt HandlerOptions) work.HandleFunc

Types

type EnqueueCheck

type EnqueueCheck func(*work.Job, *work.EnqueueOptions) ([]byte, time.Duration, error)

Func defines job uniqueness.

type EnqueuerOptions

type EnqueuerOptions struct {
	Client redis.UniversalClient
	// If returned []byte is nil, uniqness check is bypassed.
	// Returned time.Duration controls how long the unique key exists.
	UniqueFunc EnqueueCheck
}

EnqueuerOptions defines job unique key generation.

type HandleCheck

type HandleCheck func(*work.Job, *work.DequeueOptions) ([]byte, error)

type HandlerOptions

type HandlerOptions struct {
	Client     redis.UniversalClient
	UniqueFunc HandleCheck
}

Jump to

Keyboard shortcuts

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