mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-15 05:07:30 +08:00
apply go-centric architecture optimizations and document them in readme
This commit is contained in:
25
pkg/runtimecfg/snapshot.go
Normal file
25
pkg/runtimecfg/snapshot.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package runtimecfg
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
)
|
||||
|
||||
var current atomic.Value // *config.Config
|
||||
|
||||
func Set(cfg *config.Config) {
|
||||
if cfg == nil {
|
||||
return
|
||||
}
|
||||
current.Store(cfg)
|
||||
}
|
||||
|
||||
func Get() *config.Config {
|
||||
v := current.Load()
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
cfg, _ := v.(*config.Config)
|
||||
return cfg
|
||||
}
|
||||
Reference in New Issue
Block a user