实现了一个golang周期任务调度包

2018-04-04  本文已影响0人  openex

drumstick

Implement crond by Golang
https://github.com/openex27/drumstick


鼓槌(鸡腿),golang定时任务包

功能特性:

方法:

示例:

package main

import (
        "fmt"
        "time"

        drum "github.com/openex27/drumstick"
)

func sumEcho(s string, a, b int) {
        fmt.Printf("%s -> %d\n", s, a+b)
}

func main() {
        task, err := drum.NewTask(2*time.Second, sumEcho, "hello", 1, 5)
        if err != nil {
                panic(err)
        }
        task.Start()
        time.Sleep(5 * time.Second)
        task.Reset(1 * time.Second)
        time.Sleep(5 * time.Second)
        task.Stop()
        time.Sleep(1 * time.Second)
}
上一篇 下一篇

猜你喜欢

热点阅读