Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StatusRunning = "RUNNING" StatusFinished = "FINISHED" )
Functions ¶
This section is empty.
Types ¶
type CronJobLock ¶
type CronJobLock struct { ID int CreatedAt time.Time UpdatedAt time.Time JobName string `gorm:"index:idx_name,unique"` JobIdentifier string `gorm:"index:idx_name,unique"` Worker string `gorm:"not null"` Status string `gorm:"not null"` }
func (*CronJobLock) GetID ¶
func (cjb *CronJobLock) GetID() int
func (*CronJobLock) SetJobIdentifier ¶
func (cjb *CronJobLock) SetJobIdentifier(ji string)
type GormLocker ¶
type GormLocker struct {
// contains filtered or unexported fields
}
func NewGormLocker ¶
func NewGormLocker(db *gorm.DB, worker string, options ...LockOption) (*GormLocker, error)
func (*GormLocker) Close ¶
func (g *GormLocker) Close()
type LockOption ¶
type LockOption func(*GormLocker)
func WithCleanInterval ¶
func WithCleanInterval(interval time.Duration) LockOption
WithCleanInterval the time interval to run clean operation.
func WithDefaultJobIdentifier ¶
func WithDefaultJobIdentifier(precision time.Duration) LockOption
func WithJobIdentifier ¶
func WithJobIdentifier(f func(ctx context.Context, key string) string) LockOption
func WithTTL ¶
func WithTTL(ttl time.Duration) LockOption
WithTTL when the locker records in the database exceeds the ttl, it is cleaned up. to avoid excessive data in the database.
Click to show internal directories.
Click to hide internal directories.