mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
31 lines
462 B
Go
31 lines
462 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/syumai/workers/cloudflare"
|
|
"github.com/syumai/workers/cloudflare/cron"
|
|
)
|
|
|
|
func task(ctx context.Context) error {
|
|
e, err := cron.NewEvent(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(e.ScheduledTime.Unix())
|
|
|
|
cloudflare.WaitUntil(func() {
|
|
time.Sleep(1 * time.Second)
|
|
fmt.Println("Run sub task after returning from main task")
|
|
})
|
|
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
cron.ScheduleTask(task)
|
|
}
|