lock on every http req BUT LOCKS ON TELEMETRY SO BEWARE

This commit is contained in:
Bel LaPointe
2023-03-27 06:18:32 -06:00
parent f14871218d
commit 85804d6f84
5 changed files with 16 additions and 0 deletions

View File

@@ -2,12 +2,14 @@ package v01
import (
"encoding/json"
"sync"
patch "github.com/evanphx/json-patch/v5"
)
type (
config struct {
lock *sync.Mutex
Feedback configFeedback
Users map[string]configUser
Players []configPlayer
@@ -33,6 +35,8 @@ type (
)
func (cfg config) WithPatch(v interface{}) config {
cfg.lock.Lock()
defer cfg.lock.Unlock()
originalData, _ := json.Marshal(cfg)
patchData, _ := json.Marshal(v)
patcher, err := patch.DecodePatch(patchData)