Documentation
¶
Overview ¶
Package config provides configuration management for the perf-analysis service.
Package config provides configuration management for the perf-analysis service.
Index ¶
- type AnalysisConfig
- type COSStorageConfig
- type CallbackConfig
- type Config
- type DatabaseConfig
- type HTTPIngressConfig
- type IngressConfig
- type LocalStorageConfig
- type LogConfig
- type RetentionConfig
- type RetentionRule
- type SchedulerConfig
- type SourceConfig
- type StorageConfig
- type Validatable
- type ViewAuthConfig
- type ViewURLConfig
- type WebUIConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisConfig ¶
type AnalysisConfig struct {
Version string `mapstructure:"version"`
DataDir string `mapstructure:"data_dir"`
}
AnalysisConfig holds analysis-related configuration.
type COSStorageConfig ¶
type COSStorageConfig struct {
Bucket string `mapstructure:"bucket"`
Region string `mapstructure:"region"`
SecretID string `mapstructure:"secret_id"`
SecretKey string `mapstructure:"secret_key"`
Domain string `mapstructure:"domain"` // e.g., "myqcloud.com"
Scheme string `mapstructure:"scheme"` // e.g., "https" or "http"
}
COSStorageConfig holds COS-specific storage configuration.
type CallbackConfig ¶
type CallbackConfig struct {
DefaultURL string `mapstructure:"default_url"` // global default callback URL
Timeout string `mapstructure:"timeout"` // callback HTTP timeout, e.g., "10s"
MaxRetries int `mapstructure:"max_retries"` // max retry attempts
}
CallbackConfig holds callback notification configuration.
func (*CallbackConfig) GetTimeout ¶
func (c *CallbackConfig) GetTimeout() time.Duration
GetTimeout returns the callback timeout duration.
func (*CallbackConfig) Validate ¶
func (c *CallbackConfig) Validate() error
Validate validates the callback configuration.
type Config ¶
type Config struct {
Analysis AnalysisConfig `mapstructure:"analysis"`
Database DatabaseConfig `mapstructure:"database"`
Storage StorageConfig `mapstructure:"storage"`
Scheduler SchedulerConfig `mapstructure:"scheduler"`
Sources []SourceConfig `mapstructure:"sources"`
Ingress IngressConfig `mapstructure:"ingress"`
Log LogConfig `mapstructure:"log"`
Pprof *pprof.Config `mapstructure:"pprof"`
ViewURL ViewURLConfig `mapstructure:"view_url"`
WebUI WebUIConfig `mapstructure:"webui"`
Retention RetentionConfig `mapstructure:"retention"`
Callback CallbackConfig `mapstructure:"callback"`
}
Config holds all configuration for the application.
func LoadFromReader ¶
LoadFromReader loads configuration from an io.Reader (useful for testing).
type DatabaseConfig ¶
type DatabaseConfig struct {
Type string `mapstructure:"type"` // postgres or mysql
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Database string `mapstructure:"database"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
MaxConns int `mapstructure:"max_conns"`
AutoMigrate bool `mapstructure:"auto_migrate"` // auto-migrate database schema on startup
}
DatabaseConfig holds database connection configuration.
func (*DatabaseConfig) Validate ¶
func (c *DatabaseConfig) Validate() error
Validate validates the database configuration.
type HTTPIngressConfig ¶
type HTTPIngressConfig struct {
Enabled bool `mapstructure:"enabled"` // whether to enable HTTP ingress
ListenAddr string `mapstructure:"listen_addr"` // e.g., ":8081"
Path string `mapstructure:"path"` // HTTP path for receiving tasks
ReadTimeout string `mapstructure:"read_timeout"` // e.g., "30s"
WriteTimeout string `mapstructure:"write_timeout"` // e.g., "30s"
MaxBodySize int64 `mapstructure:"max_body_size"` // max request body in bytes
CallbackURL string `mapstructure:"callback_url"` // ingress-level callback URL (downgrade-save)
}
HTTPIngressConfig holds HTTP ingress configuration.
func (*HTTPIngressConfig) GetReadTimeout ¶
func (c *HTTPIngressConfig) GetReadTimeout() time.Duration
GetReadTimeout returns the read timeout duration.
func (*HTTPIngressConfig) GetWriteTimeout ¶
func (c *HTTPIngressConfig) GetWriteTimeout() time.Duration
GetWriteTimeout returns the write timeout duration.
func (*HTTPIngressConfig) Validate ¶
func (c *HTTPIngressConfig) Validate() error
Validate validates the HTTP ingress configuration (only meaningful when Enabled is true).
type IngressConfig ¶
type IngressConfig struct {
HTTP HTTPIngressConfig `mapstructure:"http"`
}
IngressConfig holds ingress configuration.
func (*IngressConfig) Validate ¶
func (c *IngressConfig) Validate() error
Validate validates the ingress configuration.
type LocalStorageConfig ¶
type LocalStorageConfig struct {
Path string `mapstructure:"path"`
}
LocalStorageConfig holds local filesystem storage configuration.
type LogConfig ¶
type LogConfig struct {
Level string `mapstructure:"level"`
OutputPath string `mapstructure:"output_path"`
Format string `mapstructure:"format"` // json or text
}
LogConfig holds logging configuration.
type RetentionConfig ¶
type RetentionConfig struct {
Default string `mapstructure:"default"` // default retention duration, e.g., "168h" (7 days)
Rules []RetentionRule `mapstructure:"rules"` // per-task-type overrides
}
RetentionConfig holds result retention configuration.
func (*RetentionConfig) GetDefaultRetention ¶
func (r *RetentionConfig) GetDefaultRetention() time.Duration
GetDefaultRetention returns the default retention duration.
func (*RetentionConfig) GetRetentionForType ¶
func (r *RetentionConfig) GetRetentionForType(taskType string) time.Duration
GetRetentionForType returns the retention duration for a given task type.
func (*RetentionConfig) Validate ¶
func (c *RetentionConfig) Validate() error
Validate validates the retention configuration.
type RetentionRule ¶
type RetentionRule struct {
TaskType string `mapstructure:"task_type"` // task type name
Duration string `mapstructure:"duration"` // retention duration, e.g., "720h" (30 days)
}
RetentionRule defines retention duration for a specific task type.
type SchedulerConfig ¶
type SchedulerConfig struct {
Enabled bool `mapstructure:"enabled"` // whether to enable the scheduler
PollInterval string `mapstructure:"poll_interval"` // e.g., "2s"
WorkerCount int `mapstructure:"worker_count"`
PrioritySlots int `mapstructure:"priority_slots"`
TaskBatchSize int `mapstructure:"task_batch_size"`
}
SchedulerConfig holds scheduler configuration.
func (*SchedulerConfig) Validate ¶
func (c *SchedulerConfig) Validate() error
Validate validates the scheduler configuration (only meaningful when Enabled is true).
type SourceConfig ¶
type SourceConfig struct {
Type string `mapstructure:"type"` // database, kafka
Name string `mapstructure:"name"` // unique name for this source
Enabled bool `mapstructure:"enabled"` // whether this source is enabled
Options map[string]interface{} `mapstructure:"options"` // source-specific options
}
SourceConfig holds configuration for a task source.
type StorageConfig ¶
type StorageConfig struct {
Type string `mapstructure:"type"` // cos or local
COS COSStorageConfig `mapstructure:"cos"`
Local LocalStorageConfig `mapstructure:"local"`
}
StorageConfig holds object storage configuration. Type selects which sub-config is active; only the matching sub-config is used.
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable defines the interface for configuration components that support validation.
type ViewAuthConfig ¶
type ViewAuthConfig struct {
Enabled bool `mapstructure:"enabled"`
Secret string `mapstructure:"secret"` // HMAC signing secret
AllowedOrigins []string `mapstructure:"allowed_origins"` // allowed origins for iframe embedding
}
ViewAuthConfig holds authentication configuration for view URL signing and validation.
func (*ViewAuthConfig) Validate ¶
func (c *ViewAuthConfig) Validate() error
Validate validates the view URL authentication configuration.
type ViewURLConfig ¶
type ViewURLConfig struct {
BaseURL string `mapstructure:"base_url"` // e.g., "https://perf.example.com"
Auth ViewAuthConfig `mapstructure:"auth"`
}
ViewURLConfig holds configuration for generating signed view URLs. This is used by analyzer to produce callback URLs and by WebUI to validate them.
func (*ViewURLConfig) Validate ¶
func (c *ViewURLConfig) Validate() error
Validate validates the view URL configuration.
type WebUIConfig ¶
type WebUIConfig struct {
Enabled bool `mapstructure:"enabled"` // whether to start embedded WebUI server
Port int `mapstructure:"port"` // WebUI listen port
CacheDir string `mapstructure:"cache_dir"` // local cache directory for remote storage
CacheMax int64 `mapstructure:"cache_max"` // max cache size in bytes (0 = unlimited)
}
WebUIConfig holds WebUI HTTP server configuration.
func (*WebUIConfig) Validate ¶
func (c *WebUIConfig) Validate() error
Validate validates the WebUI configuration (only meaningful when Enabled is true).