first
This commit is contained in:
24
backend/internal/settings/runtime.go
Normal file
24
backend/internal/settings/runtime.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package settings
|
||||
|
||||
import "sync"
|
||||
|
||||
type Runtime struct {
|
||||
mu sync.RWMutex
|
||||
current Settings
|
||||
}
|
||||
|
||||
func NewRuntime(initial Settings) *Runtime {
|
||||
return &Runtime{current: initial}
|
||||
}
|
||||
|
||||
func (r *Runtime) Get() Settings {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
return r.current
|
||||
}
|
||||
|
||||
func (r *Runtime) Update(next Settings) {
|
||||
r.mu.Lock()
|
||||
r.current = next
|
||||
r.mu.Unlock()
|
||||
}
|
||||
Reference in New Issue
Block a user