From 72f5a6798989924518203f860c9da13c01cd2d04 Mon Sep 17 00:00:00 2001 From: Bennett Wetters Date: Wed, 31 Jan 2024 18:25:34 +0100 Subject: [PATCH] Move persistence stuff to own package --- main.go | 6 +++--- {util => persistence}/persistentState.go | 2 +- {util => persistence}/persistentStateDir.go | 2 +- {util => persistence}/persistentStateDir_linux.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename {util => persistence}/persistentState.go (99%) rename {util => persistence}/persistentStateDir.go (74%) rename {util => persistence}/persistentStateDir_linux.go (73%) diff --git a/main.go b/main.go index 609fff1..3983cbd 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/util/persistentState.go b/persistence/persistentState.go similarity index 99% rename from util/persistentState.go rename to persistence/persistentState.go index 5d1e8bd..01e1912 100644 --- a/util/persistentState.go +++ b/persistence/persistentState.go @@ -1,4 +1,4 @@ -package util +package persistence import ( "encoding/json" diff --git a/util/persistentStateDir.go b/persistence/persistentStateDir.go similarity index 74% rename from util/persistentStateDir.go rename to persistence/persistentStateDir.go index 96a9749..432dcff 100644 --- a/util/persistentStateDir.go +++ b/persistence/persistentStateDir.go @@ -1,6 +1,6 @@ //go:build !linux -package util +package persistence const ( persistentStateDir = "./" diff --git a/util/persistentStateDir_linux.go b/persistence/persistentStateDir_linux.go similarity index 73% rename from util/persistentStateDir_linux.go rename to persistence/persistentStateDir_linux.go index 9f36a47..65c0f8d 100644 --- a/util/persistentStateDir_linux.go +++ b/persistence/persistentStateDir_linux.go @@ -1,4 +1,4 @@ -package util +package persistence const ( persistentStateDir = "/var/lib/spaceapid/"