Documentation
¶
Overview ¶
* @Author: liziwei01 * @Date: 2023-10-31 20:07:09 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:34:07 * @Description: 定时器
* @Author: liziwei01 * @Date: 2023-10-31 20:07:29 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:34:17 * @Description: 模拟crontab
* @Author: liziwei01 * @Date: 2023-10-31 20:05:52 * @LastEditors: liziwei01 * @LastEditTime: 2023-11-01 11:34:36 * @Description: 打包时间函数
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Producer ¶
type Producer interface { // 获取当前值(之前已产生的) Get() interface{} // 注册 RegisterCallBack(callBackFunc func(value interface{})) // 停止 Stop() }
Producer 生产者
func NewProducer ¶
NewProducer 创建一个具有定时器的生产者 如 duration= 5分钟,则每5分钟产生一个新的value 新生成的值会通过回调告知使用者,或者也可以通过Get方法读取到
type SimpleCron ¶
type SimpleCron struct {
// contains filtered or unexported fields
}
SimpleCron 一个简单的定时任务管理器
func NewSimpleCron ¶
func NewSimpleCron(duration time.Duration) *SimpleCron
NewSimpleCron 创建一个定时任务管理器
参数 duration 用于控制运行间隔 如 1*time.Minute 为每分钟运行一次(每分钟到达的时候触发) 1*time.Minute 等效于 unix 的 */1 5*time.Minute 等效于 unix 的 */5
func (*SimpleCron) AddJob ¶
func (sc *SimpleCron) AddJob(f func())
AddJob 添加任务 添加的任务在运行的时候会新启一个 gor 并行的运行
Click to show internal directories.
Click to hide internal directories.