Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
feat: add cronjobs go module (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e authored Apr 16, 2024
1 parent 12ce458 commit 1b45cdc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
34 changes: 34 additions & 0 deletions go/cronjobs/cronjobs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//ftl:module cronjobs
package cronjobs

import (
"context"
"fmt"
"time"
)

//ftl:cron */10 * * * * * *
func EveryTenSeconds(ctx context.Context) error {
fmt.Printf("Every ten seconds: %d\n", time.Now().Second())
return nil
}

//ftl:cron 0 * * * * * *
func EveryMinute(ctx context.Context) error {
fmt.Printf("Every minute %v\n", time.Now().Minute())
return nil
}

//ftl:cron 0 0 0 * * * *
func EveryDay(ctx context.Context) error {
fmt.Printf("Every day\n")
return nil
}

//ftl:cron */3 * * * * * *
func LongAndFrequentCronJob(ctx context.Context) error {
fmt.Printf("Long and frequent: Started\n")
time.Sleep(time.Second * 30)
fmt.Printf("Long and frequent: Ended\n")
return nil
}
2 changes: 2 additions & 0 deletions go/cronjobs/ftl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module = "cronjobs"
language = "go"
5 changes: 5 additions & 0 deletions go/cronjobs/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module ftl/cronjobs

go 1.22.2

replace github.com/TBD54566975/ftl => ../../../ftl
Empty file added go/cronjobs/go.sum
Empty file.

0 comments on commit 1b45cdc

Please sign in to comment.