Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailedToConnectToLocker = errors.New("looper - failed to connect to locker") ErrFailedToObtainLock = errors.New("looper - failed to obtain lock") ErrFailedToReleaseLock = errors.New("looper - failed to release lock") ErrFailedToCreateLockTable = errors.New("looper - failed to create lock table") ErrFailedToCheckLockExistence = errors.New("looper - failed to check lock existence") )
Functions ¶
func SetPanicHandler ¶
func SetPanicHandler(handler PanicHandlerFunc)
Types ¶
type HookAfterJob ¶
type HookAfterJobError ¶
type HookBeforeJob ¶
type HookBeforeJob func(jobName string)
type Job ¶
type Job struct { // Job function which get triggered by looper. JobFn JobFn // Name of the job. Name string // Timeout for job, maximum time, the job can run, after timeout the job get killed. Timeout time.Duration // Wait duration before next job execution after successful execution of previous job. WaitAfterSuccess time.Duration // Wait duration before next job execution after unsuccessful execution of previous job. WaitAfterError time.Duration // If job is Active, and can be started. Active bool // If job is started. Started bool // If job is currently running. Running bool // Last time the job ran. LastRun time.Time // Count of successful job runs. RunCountSuccess uint64 // Count of unsuccessful job runs. RunCountError uint64 // Copy of last error, that occured. LastError error // Hook function before job runs. BeforeJob HookBeforeJob // Hook function after job runs successfully. AfterJob HookAfterJob // Hook function after job runs unsuccessfully. AfterJobError HookAfterJobError // If the job should use locker WithLocker bool // contains filtered or unexported fields }
type Locker ¶ added in v0.0.5
type Locker interface {
Lock(ctx context.Context, key string, timeout time.Duration) (Lock, error)
}
Lock if an error is returned by lock, the job will not be scheduled.
type Looper ¶
type Looper struct {
// contains filtered or unexported fields
}
Looper
func (*Looper) RegisterHooks ¶
func (l *Looper) RegisterHooks( beforeJob HookBeforeJob, afterJob HookAfterJob, afterJobError HookAfterJobError, )
func (*Looper) StartJobByName ¶
Click to show internal directories.
Click to hide internal directories.