Moved some code around and updated the README

This commit is contained in:
ChaoticByte 2024-07-22 18:41:22 +02:00
parent 368445e3a5
commit e9f39d25b4
No known key found for this signature in database
10 changed files with 135 additions and 149 deletions

21
persistent_data.go Normal file
View file

@ -0,0 +1,21 @@
// Copyright (c) 2024 Julian Müller (ChaoticByte)
package main
import (
"time"
)
type PersistentData struct {
// {endpoint id 1: time last published, endpoint id 2: ..., ...}
LastPublished map[string]time.Time `json:"last_published"`
}
func NewPersistentData(c Config) PersistentData {
// Initial persistent data
d := PersistentData{LastPublished: map[string]time.Time{}}
for _, e := range apiEndpoints {
d.LastPublished[e.Id] = time.Now().Add(-time.Hour * 24) // a day ago
}
return d
}