Move persistence stuff to own package

This commit is contained in:
Bendodroid 2024-01-31 18:25:34 +01:00
parent 742fb2be58
commit 72f5a67989
Signed by: bendodroid
GPG key ID: 3EEE19A0F73D5FFC
4 changed files with 6 additions and 6 deletions

View file

@ -12,8 +12,8 @@ import (
"git.hamburg.ccc.de/ccchh/spaceapid/config"
"git.hamburg.ccc.de/ccchh/spaceapid/handlers"
"git.hamburg.ccc.de/ccchh/spaceapid/persistence"
"git.hamburg.ccc.de/ccchh/spaceapid/types"
"git.hamburg.ccc.de/ccchh/spaceapid/util"
)
var (
@ -39,7 +39,7 @@ func main() {
conf := config.ParseConfiguration()
// Merge old state if present
util.MergeOldState(&conf.Response)
persistence.MergeOldState(&conf.Response)
// Register signal handler
sc := make(chan os.Signal, 1)
@ -47,7 +47,7 @@ func main() {
go func(resp *types.SpaceAPIResponseV14) {
<-sc
log.Println("Saving state and shutting down...")
util.SaveCurrentState(*resp)
persistence.SaveCurrentState(*resp)
os.Exit(0)
}(&conf.Response)

View file

@ -1,4 +1,4 @@
package util
package persistence
import (
"encoding/json"

View file

@ -1,6 +1,6 @@
//go:build !linux
package util
package persistence
const (
persistentStateDir = "./"

View file

@ -1,4 +1,4 @@
package util
package persistence
const (
persistentStateDir = "/var/lib/spaceapid/"