2023-04-30 10:35:04 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/syumai/workers/cloudflare"
|
2023-04-30 10:54:24 +09:00
|
|
|
"github.com/syumai/workers/cloudflare/cron"
|
2023-04-30 10:35:04 +09:00
|
|
|
)
|
|
|
|
|
2023-04-30 11:04:28 +09:00
|
|
|
func task(ctx context.Context, event *cron.Event) error {
|
2023-04-30 10:35:04 +09:00
|
|
|
fmt.Println(cloudflare.Getenv(ctx, "HELLO"))
|
|
|
|
|
|
|
|
if event.ScheduledTime.Minute()%2 == 0 {
|
|
|
|
return errors.New("even numbers cause errors")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-04-30 10:54:24 +09:00
|
|
|
cron.ScheduleTask(task)
|
2023-04-30 10:35:04 +09:00
|
|
|
}
|