Moved some code around and updated the README
This commit is contained in:
parent
368445e3a5
commit
e9f39d25b4
10 changed files with 135 additions and 149 deletions
21
persistent_data.go
Normal file
21
persistent_data.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue