NewDefaultConfig returns value, not pointer; Nested configs are defined as value

This commit is contained in:
DarthSim
2025-09-06 01:38:32 +03:00
parent 4789810b18
commit ac03563506
27 changed files with 133 additions and 128 deletions

View File

@@ -5,6 +5,7 @@ import (
"runtime"
"github.com/imgproxy/imgproxy/v3/config"
"github.com/imgproxy/imgproxy/v3/ensure"
)
// Config represents handler config
@@ -14,8 +15,8 @@ type Config struct {
}
// NewDefaultConfig creates a new configuration with defaults
func NewDefaultConfig() *Config {
return &Config{
func NewDefaultConfig() Config {
return Config{
RequestsQueueSize: 0,
Workers: runtime.GOMAXPROCS(0) * 2,
}
@@ -23,9 +24,7 @@ func NewDefaultConfig() *Config {
// LoadConfigFromEnv loads config from environment variables
func LoadConfigFromEnv(c *Config) (*Config, error) {
if c == nil {
c = NewDefaultConfig()
}
c = ensure.Ensure(c, NewDefaultConfig)
c.RequestsQueueSize = config.RequestsQueueSize
c.Workers = config.Workers