|
| 1 | +# DynConf |
| 2 | + |
| 3 | +[](https://pkg.go.dev/github.com/yourusername/dynconf) |
| 4 | +[](https://goreportcard.com/report/github.com/yourusername/dynconf) |
| 5 | +[](https://codecov.io/gh/yourusername/dynconf) |
| 6 | + |
| 7 | +DynConf is a type-safe dynamic configuration management library for Go applications. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- Type-safe configuration using Go generics |
| 12 | +- Zero-downtime configuration updates |
| 13 | +- Multiple configuration sources (file, etcd, Consul, Redis) |
| 14 | +- Validation and automatic rollback |
| 15 | +- Gradual rollout strategies |
| 16 | +- Metrics and monitoring |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +```bash |
| 21 | +go get github.com/samuelarogbonlo/dynconf |
| 22 | +``` |
| 23 | + |
| 24 | +## Quick Start |
| 25 | + |
| 26 | +```go |
| 27 | +package main |
| 28 | + |
| 29 | +import ( |
| 30 | + "context" |
| 31 | + "log" |
| 32 | + "time" |
| 33 | + "github.com/samuelarogbonlo/dynconf" |
| 34 | +) |
| 35 | + |
| 36 | +type AppConfig struct { |
| 37 | + ServerPort int `json:"server_port"` |
| 38 | + Timeout time.Duration `json:"timeout"` |
| 39 | +} |
| 40 | + |
| 41 | +func main() { |
| 42 | + cfg := dynconf.New[AppConfig]( |
| 43 | + dynconf.WithValidation[AppConfig](func(old, new AppConfig) error { |
| 44 | + if new.ServerPort < 1024 { |
| 45 | + return errors.New("server port must be >= 1024") |
| 46 | + } |
| 47 | + return nil |
| 48 | + }), |
| 49 | + dynconf.WithRollback[AppConfig](true), |
| 50 | + ) |
| 51 | + |
| 52 | + changes, _ := cfg.Watch(context.Background()) |
| 53 | + go func() { |
| 54 | + for newCfg := range changes { |
| 55 | + log.Printf("Config updated: %+v", newCfg) |
| 56 | + } |
| 57 | + }() |
| 58 | + |
| 59 | + // Your application logic |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Documentation |
| 64 | + |
| 65 | +- [Getting Started](docs/getting-started.md) |
| 66 | +- [Configuration Sources](docs/configuration-sources.md) |
| 67 | +- [Rollout Strategies](docs/rollout-strategies.md) |
| 68 | +- [Metrics](docs/metrics.md) |
| 69 | + |
| 70 | +## Contributing |
| 71 | + |
| 72 | +See [Contributing Guide](docs/contributing.md) for guidelines. |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +MIT License - see [LICENSE](LICENSE) for details. |
0 commit comments