gorealconf
is a powerful, type-safe dynamic configuration management library designed for modern Go applications. With support for real-time updates, multiple configuration sources, and gradual rollouts, it ensures zero-downtime deployments while maintaining operational stability.
- Documentation
- Installation
- Quick Start
- Key Features
- Requirements
- Advanced Features
- Examples
- Security
- Support
- Stability Status
- Contributing
- License
Latest version:
go get github.com/samuelarogbonlo/gorealconf
Specific version:
go get github.com/samuelarogbonlo/[email protected]
- Define your configuration:
type AppConfig struct {
ServerPort int `json:"server_port"`
Timeout time.Duration `json:"timeout"`
}
- Create and use configuration:
cfg := gorealconf.New[AppConfig]()
// Add validation
cfg = gorealconf.New[AppConfig](
gorealconf.WithValidation[AppConfig](func(old, new AppConfig) error {
if new.ServerPort < 1024 {
return errors.New("port must be >= 1024")
}
return nil
}),
)
// Watch for changes
changes, _ := cfg.Watch(context.Background())
go func() {
for newCfg := range changes {
log.Printf("Config updated: %+v", newCfg)
}
}()
type Config struct {
Port int `json:"port"`
Timeout time.Duration `json:"timeout"`
}
cfg := gorealconf.New[Config]()
cfg := gorealconf.New[Config](
gorealconf.WithSource(fileSource),
gorealconf.WithSource(etcdSource),
)
cfg := gorealconf.New[Config](
gorealconf.WithValidation[Config](validateConfig),
gorealconf.WithRollback[Config](true),
)
strategy := gorealconf.NewPercentageStrategy(10)
rollout := gorealconf.NewRollout[Config](cfg).
WithStrategy(strategy)
metrics := gorealconf.NewMetrics("myapp")
cfg.WithMetrics(metrics)
- Go 1.21 or higher
- Compatible with:
- etcd v3.5+
- Consul v1.12+
- Redis v6+
- Prometheus for metrics (optional)
- Type-safe Configuration: Ensure your configurations are validated at compile time.
- Multiple Configuration Sources: Combine Redis, etcd, and files for flexibility.
- Automatic Validation & Rollback: Catch and rollback bad configurations automatically.
- Gradual Rollouts: Deploy new configurations incrementally.
- Metrics Integration: Export configuration change metrics via Prometheus.
Explore the examples provided to understand how to use gorealconf
in different scenarios:
- Basic Usage: Learn how to set up a simple configuration.
- Multi-source Configuration: Use multiple configuration backends with priority handling.
- Webserver Integration: Configure and manage dynamic settings for a webserver.
- Database Configuration: Dynamically update and manage database configurations.
- Gradual Rollouts: Deploy configuration updates incrementally and safely.
- Complete Setup: A fully functional example combining multiple sources, validation, and rollouts.
Each example includes inline comments and demonstrates real-world usage scenarios. Visit the examples/ directory for the full code.
For security concerns, please email [email protected]
- Report bugs via GitHub Issues
- Join discussions in GitHub Discussions
- Get community help via GitHub Discussions
Production-Ready: v0.1.0
See Contributing Guide for guidelines.
MIT License - see LICENSE for details.