sql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimerOverdue = fmt.Errorf("timer overdue")

Functions

This section is empty.

Types

type DBTimer

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

func NewDBTimer

func NewDBTimer(service string, db *gorm.DB, opts ...Option) *DBTimer

func (*DBTimer) Cancel

func (t *DBTimer) Cancel(key string) error

func (*DBTimer) RegisterTimerHandler

func (t *DBTimer) RegisterTimerHandler(cb ddd.TimerHandler)

func (*DBTimer) RunCron

func (t *DBTimer) RunCron(key, cronExp string, data []byte) error

func (*DBTimer) RunOnce

func (t *DBTimer) RunOnce(key string, runTime time.Time, data []byte) error

func (*DBTimer) Start

func (t *DBTimer) Start(ctx context.Context)

type Option

type Option func(opt *Options)

type Options

type Options struct {
	RunInterval time.Duration
	Logger      logr.Logger
}

type TimerJob

type TimerJob struct {
	ID        int64       `gorm:"primaryKey;column:id;autoIncrement"`
	Service   string      `gorm:"column:service;type:varchar(30)"`
	Key       string      `gorm:"column:key;type:varchar(30);uniqueIndex;not null"`
	Cron      string      `gorm:"column:cron;type:varchar(30);null"`
	NextTime  time.Time   `gorm:"column:next_time;type:datetime;index;not null"`
	Status    TimerStatus `gorm:"column:status;type:tinyint"`
	Msg       string      `gorm:"column:msg;type:varchar(128)"`
	Payload   []byte      `gorm:"column:payload;type:text"`
	CreatedAt time.Time   `gorm:"index;type:datetime"`
}

func (*TimerJob) Close

func (t *TimerJob) Close(err error)

func (*TimerJob) Next

func (t *TimerJob) Next() error

func (*TimerJob) Reset

func (t *TimerJob) Reset() error

func (*TimerJob) TableName

func (t *TimerJob) TableName() string

type TimerStatus

type TimerStatus int
const (
	TimerToRun    TimerStatus = 1
	TimerFinished TimerStatus = 2
	TimerFailed   TimerStatus = 3
)

Jump to

Keyboard shortcuts

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