Documentation
¶
Overview ¶
Package schedule is to help you manage schedule tasks.
Example ¶
package main
import (
"github.com/boxgo/box"
"github.com/boxgo/box/pkg/logger"
"github.com/boxgo/box/pkg/schedule"
)
func main() {
onceHandler := func(args map[string]interface{}) error {
logger.Info("once handler executing...", args)
return nil
}
timingHandler := func(args map[string]interface{}) error {
logger.Info("timing handler executing...", args)
return nil
}
sch := schedule.StdConfig("default").Build(schedule.WithHandler(onceHandler, timingHandler))
app := box.New(
box.WithBoxes(sch),
)
if err := app.Run(); err != nil {
logger.Fatal(err)
}
}
Index ¶
Examples ¶
Constants ¶
View Source
const ( Stop = Type(0) Once = Type(1) Timing = Type(2) OnceAndTiming = Type(3) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Type Type `config:"type" desc:"Stop: 0, Once: 1, Timing: 2, OnceAndTiming: 3"`
Spec string `config:"spec" desc:"Cron spec info"`
Compete bool `config:"compete" desc:"Only winner can exec schedule"`
AutoUnlock bool `config:"autoUnlock" desc:"Auto unlock after task finish"`
LockSeconds int `config:"lockSeconds" desc:"Lock ttl"`
Args map[string]interface{} `config:"args" desc:"Schedule arguments"`
// contains filtered or unexported fields
}
func DefaultConfig ¶
func (*Config) Build ¶
func (c *Config) Build(optionFunc ...OptionFunc) *Schedule
type OptionFunc ¶
type OptionFunc func(*Config)
func WithHandler ¶
func WithHandler(onceHandler, timingHandler Handler) OptionFunc
func WithLocker ¶
func WithLocker(locker locker.MutexLocker) OptionFunc
Click to show internal directories.
Click to hide internal directories.