Merge pull request 'layed out goroutine' (#2) from diyhrt/interval_fetching into main
Reviewed-on: #2
This commit is contained in:
commit
addaade269
@ -1,7 +1,9 @@
|
||||
package diyhrt
|
||||
|
||||
type DiyHrtConfig struct {
|
||||
ApiKey string
|
||||
ApiKey string
|
||||
FetchIntervals int
|
||||
|
||||
StoreFilter StoreFilter
|
||||
ListingFilter ListingFilter
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ func NewConfig() Config {
|
||||
Port: 5500,
|
||||
},
|
||||
DiyHrt: diyhrt.DiyHrtConfig{
|
||||
ApiKey: os.Getenv("API_KEY"),
|
||||
ApiKey: os.Getenv("API_KEY"),
|
||||
FetchIntervals: 60, // fetch every hour
|
||||
StoreFilter: diyhrt.StoreFilter{
|
||||
Limit: 0,
|
||||
IncludeIds: []int{7},
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gitea.elara.ws/Hazel/transfem-startpage/internal/cache"
|
||||
"gitea.elara.ws/Hazel/transfem-startpage/internal/rendering"
|
||||
@ -12,12 +13,26 @@ import (
|
||||
|
||||
var Config = rendering.NewConfig()
|
||||
|
||||
func StartFetching() {
|
||||
for {
|
||||
log.Println("Fetch DiyHrt data...")
|
||||
Config.FetchDiyHrt()
|
||||
time.Sleep(time.Duration(Config.DiyHrt.FetchIntervals) * time.Second)
|
||||
|
||||
if Config.DiyHrt.FetchIntervals == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Start(profile string) error {
|
||||
err := Config.ScanForConfigFile(profile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go StartFetching()
|
||||
|
||||
err = Config.FetchDiyHrt()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
@ -1 +1 @@
|
||||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
||||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
Loading…
x
Reference in New Issue
Block a user