LiteCron 分布式计划任务运行框架 项目简介
LiteCron 是一个基于 Go 的分布式计划任务运行框架,可以很容易的集成到 web app 中。它基于 Redis 实现分布式锁,无需特别的存储依赖。案例在 web app 中运行计划任务。构建分布式计划任务服务以替换系统计划任务服务。用法//Step 1: init default cron client.
litecron.InitDefaultCron(&litecron.MutexConfig{
RedisConfig:&litecron.RedisConfig{
DNS:"127.0.0.1:6379",
},
Prefix:"litecron/examples/defaults/",
Factor:0.01,
})
//Register a cron job for every 2 seconds.
litecron.Register("@every 2s",exampleHandle)
go litecron.Run()
time.Sleep(10 * time.Second)
// Output:Demodefault cron clientwithout default cron clientmock multi processor
litecron.InitDefaultCron(&litecron.MutexConfig{
RedisConfig:&litecron.RedisConfig{
DNS:"127.0.0.1:6379",
},
Prefix:"litecron/examples/defaults/",
Factor:0.01,
})
//Register a cron job for every 2 seconds.
litecron.Register("@every 2s",exampleHandle)
go litecron.Run()
time.Sleep(10 * time.Second)
// Output:Demodefault cron clientwithout default cron clientmock multi processor