stuttgart-things / sweatShop-scheduler

periodically calls sweatShop-fetcher for scanning git repositories
Apache License 2.0
0 stars 0 forks source link

RESEARCH #1

Open patrick-hermann-sva opened 1 year ago

patrick-hermann-sva commented 1 year ago
patrick-hermann-sva commented 1 year ago

trigger sweatshop-fetcher every x seconds sould be possible to implement w/ gocron

example dummy code

package main

// 1
import (
 "fmt"
 "time"

 "github.com/go-co-op/gocron"
)

// 2
func hello(name string) {
 message := fmt.Sprintf("Hi, %v", name)
 fmt.Println(message)
}

func runCronJobs() {
 // 3
 s := gocron.NewScheduler(time.UTC)

 // 4
 s.Every(300).Seconds().Do(func() {
  hello("whatever")
 })

 // 5
 s.StartBlocking()
}

// 6
func main() {
 runCronJobs()
}