cron

package module
v0.0.0-...-d73744a Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 14 Imported by: 0

README

CRON

go get -u github.com/rumorshub/cron

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const LockerPluginName = "cron.locker"
View Source
const PluginName = "cron"

Variables

View Source
var ErrExpressionEmpty = errors.New("expression is empty")

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxConcurrentJobs  int  `mapstructure:"max_concurrent_jobs" json:"max_concurrent_jobs,omitempty" bson:"max_concurrent_jobs,omitempty"`
	TagsUnique         bool `mapstructure:"tags_unique" json:"tags_unique,omitempty" bson:"tags_unique,omitempty"`
	WaitForScheduleAll bool `mapstructure:"wait_for_schedule_all" json:"wait_for_schedule_all,omitempty" bson:"wait_for_schedule_all,omitempty"`
	WaitForSchedule    bool `mapstructure:"wait_for_schedule" json:"wait_for_schedule,omitempty" bson:"wait_for_schedule,omitempty"`
}

func (*Config) InitDefaults

func (c *Config) InitDefaults()

type Configurer

type Configurer interface {
	Has(name string) bool
	UnmarshalKey(name string, out interface{}) error
}

type LockerConfig

type LockerConfig struct {
	// Tries can be used to set the number of times lock acquire is attempted.
	Tries *int `mapstructure:"tries" json:"tries,omitempty" bson:"tries,omitempty"`

	// DriftFactor can be used to set the clock drift factor.
	DriftFactor *float64 `mapstructure:"drift_factor" json:"drift_factor,omitempty" bson:"drift_factor,omitempty"`

	// TimeoutFactor can be used to set the timeout factor.
	TimeoutFactor *float64 `mapstructure:"timeout_factor" json:"timeout_factor,omitempty" bson:"timeout_factor,omitempty"`

	// Expiry can be used to set the expiry of a mutex to the given value.
	Expiry *time.Duration `mapstructure:"expiry" json:"expiry,omitempty" bson:"expiry,omitempty"`

	// RetryDelay can be used to set the amount of time to wait between retries.
	RetryDelay *time.Duration `mapstructure:"retry_delay" json:"retry_delay,omitempty" bson:"retry_delay,omitempty"`
}

func (*LockerConfig) InitDefaults

func (c *LockerConfig) InitDefaults()

func (*LockerConfig) Options

func (c *LockerConfig) Options() []redsync.Option

type LockerPlugin

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

func (*LockerPlugin) Init

func (p *LockerPlugin) Init(cfg Configurer, maker RedisMaker, scheduler Scheduler) error

func (*LockerPlugin) Name

func (p *LockerPlugin) Name() string

func (*LockerPlugin) Serve

func (p *LockerPlugin) Serve() chan error

func (*LockerPlugin) Stop

func (p *LockerPlugin) Stop(_ context.Context) error

type Logger

type Logger interface {
	NamedLogger(name string) *slog.Logger
}

type Plugin

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

func (*Plugin) Collects

func (p *Plugin) Collects() []*dep.In

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer, logger Logger) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Provides

func (p *Plugin) Provides() []*dep.Out

func (*Plugin) Scheduler

func (p *Plugin) Scheduler() Scheduler

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop(_ context.Context) error

type RedisMaker

type RedisMaker interface {
	MakeRedis(name string) (redis.UniversalClient, error)
}

type Scheduler

type Scheduler interface {
	WithDistributedLocker(locker gocron.Locker)

	StartAsync()
	Stop()
	IsRunning() bool

	Jobs() []*gocron.Job
	GetAllTags() []string

	Remove(jobFun interface{})
	RemoveByReference(job *gocron.Job)
	RemoveByTag(tag string) error
	RemoveByTags(tags ...string) error
	RemoveByTagsAny(tags ...string) error

	FindJobsByTag(tags ...string) ([]*gocron.Job, error)
	TaskPresent(jobFun interface{}) bool

	Clear()

	RegisterEventListeners(eventListeners ...gocron.EventListener)

	UpdateJob(job *gocron.Job) error
	AddTask(expression string, jobFun interface{}, name string, tags ...string) (*gocron.Job, error)
}

type Task

type Task interface {
	Expression() string
	Execute(job gocron.Job) error
}

type TaskWrapper

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

func NewTaskWrapper

func NewTaskWrapper(name, expression string, execute func(job gocron.Job) error) *TaskWrapper

func (*TaskWrapper) AddTags

func (t *TaskWrapper) AddTags(tags ...string) *TaskWrapper

func (*TaskWrapper) Execute

func (t *TaskWrapper) Execute(job gocron.Job) error

func (*TaskWrapper) Expression

func (t *TaskWrapper) Expression() string

func (*TaskWrapper) Name

func (t *TaskWrapper) Name() string

func (*TaskWrapper) SetTags

func (t *TaskWrapper) SetTags(tags ...string) *TaskWrapper

func (*TaskWrapper) Tags

func (t *TaskWrapper) Tags() []string

type Tasks

type Tasks interface {
	Tasks() []interface{}
}

type TasksWrapper

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

func NewTasksWrapper

func NewTasksWrapper(tasks ...interface{}) TasksWrapper

func (TasksWrapper) Tasks

func (t TasksWrapper) Tasks() []interface{}

Jump to

Keyboard shortcuts

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