1515 */
1616
1717/*
18- Package gs_dync provides dynamic configuration binding and
19- refresh capabilities for Go applications.
18+ Package gs_dync provides dynamic configuration binding and refresh capabilities for Go applications.
2019
21- Features:
22- - Thread-safe atomic.Value based storage with automatic type conversion
23- - Property change listeners with channel-based notifications
24- - Hierarchical configuration key resolution (supports nested structs and map keys)
25- - Live configuration updates with granular change detection
26- - JSON serialization support for configuration values
20+ This package is built on thread-safe atomic.Value storage with automatic type conversion and supports change listeners,
21+ making it suitable for components or services that need to react to configuration updates at runtime.
22+
23+ Key Features:
24+ - Type-safe and thread-safe encapsulation of configuration values
25+ - Change notification mechanism using channels
26+ - Hierarchical key resolution for nested structs and map keys
27+ - Fine-grained refresh logic that only updates affected objects
28+ - JSON serialization support for value persistence and transmission
2729
2830Examples:
2931
@@ -33,7 +35,7 @@ Basic value binding:
3335 _ = v.onRefresh(conf.Map(map[string]any{"key": 42}), conf.BindParam{Key: "key"})
3436 fmt.Print(v.Value()) // Output: 42
3537
36- Struct binding with nested configuration :
38+ Binding nested structs :
3739
3840 type Config struct {
3941 Server struct {
@@ -44,11 +46,6 @@ Struct binding with nested configuration:
4446 var cfg Config
4547 _ = p.RefreshField(reflect.ValueOf(&cfg), conf.BindParam{Key: "config"})
4648
47- JSON serialization:
48-
49- b, _ := json.Marshal(map[string]any{"key": &v})
50- fmt.Print(string(b)) // Output: {"key":42}
51-
5249Change notification:
5350
5451 listener := v.NewListener()
@@ -57,6 +54,9 @@ Change notification:
5754 fmt.Print("value changed!")
5855 }()
5956 _ = v.onRefresh(conf.Map(map[string]any{"key": 100}), conf.BindParam{Key: "key"})
57+
58+ This package is ideal for use cases that require hot-reloading of configuration, have complex config structures,
59+ or demand reactive behavior to configuration changes.
6060*/
6161package gs_dync
6262
0 commit comments