1234567891011121314151617181920212223242526272829303132 |
- package comopts
- import "github.com/spf13/pflag"
- // FeatureOptions 开启性能分析和指标选项
- type FeatureOptions struct {
- EnableProfiling bool `json:"profiling" mapstructure:"profiling"`
- EnableMetrics bool `json:"enable-metrics" mapstructure:"enable-metrics"`
- }
- func NewFeatureOptions() *FeatureOptions {
- return &FeatureOptions{
- EnableMetrics: false,
- EnableProfiling: false,
- }
- }
- func (o *FeatureOptions) Validate() []error {
- return []error{}
- }
- func (o *FeatureOptions) AddFlags(fs *pflag.FlagSet) {
- if fs == nil {
- return
- }
- fs.BoolVar(&o.EnableProfiling, "feature.profiling", o.EnableProfiling,
- "Enable profiling via web interface host:port/debug/pprof/")
- fs.BoolVar(&o.EnableMetrics, "feature.enable-metrics", o.EnableMetrics,
- "Enables metrics on the apiserver at /metrics")
- }
|