Use dynamic configuration selectively and effectively by following these principles: 1. Only use dynamic config for values that need runtime modification:
Use dynamic configuration selectively and effectively by following these principles:
// Use dynamic config for runtime-configurable values SlowRequestThreshold: dc.GetDurationProperty( dynamicconfig.SlowRequestLogThreshold, 5 * time.Second, )
2. Document config parameters with clear impact descriptions:
```go
// Bad: Unclear impact
MaxRetryAttempts = NewGlobalIntSetting(
"workflow.maxRetryAttempts",
5,
"Maximum retry attempts allowed"
)
// Good: Clear threshold impact
MaxRetryAttempts = NewGlobalIntSetting(
"workflow.maxRetryAttempts",
5,
"Maximum retry attempts allowed. When exceeded, workflow fails permanently"
)
// Good: Injecting specific config function func NewHandler(thresholdFn dynamicconfig.DurationPropertyFn) { threshold := thresholdFn() } ```
This approach improves testability, maintainability, and makes configuration dependencies explicit while ensuring configs are used only where runtime modification is necessary.
Enter the URL of a public GitHub repository