distributednooverlapping

package
v2.26.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(mu Mutex, opts ...Option) cron.Middleware

Types

type DefaultTTLJobWithMutex

type DefaultTTLJobWithMutex struct{}

DefaultTTLJobWithMutex is a default implementation of JobWithMutex.

func (DefaultTTLJobWithMutex) GetMutexTTL

func (DefaultTTLJobWithMutex) GetMutexTTL() time.Duration

type JobWithMutex

type JobWithMutex interface {
	cron.Job

	// GetMutexKey returns the key of the mutex.
	GetMutexKey() string

	// GetMutexTTL returns the ttl of the mutex.
	// The ttl suggests greater than the running time of the job.
	GetMutexTTL() time.Duration
}

type Mutex

type Mutex interface {
	// Lock tries to acquire the mutex for the job.
	// If the mutex is acquired, it returns true.
	// If the mutex is not acquired, it returns false.
	Lock(ctx context.Context, job JobWithMutex) (bool, error)

	// Unlock releases the mutex for the job.
	Unlock(ctx context.Context, job JobWithMutex) error
}

type Option

type Option func(*options)

func WithLogger

func WithLogger(logger cron.Logger) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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