This commit is contained in:
Vladislav Kunetskiy
2026-10-21 21:22:42 +03:00
parent f4bd361f12
commit 464db7fdd6
238 changed files with 13332 additions and 704 deletions
+19 -7
View File
@@ -28,19 +28,26 @@ const (
)
type Config struct {
Env string `mapstructure:"env" validate:"omitempty,eq=dev"`
Server Server `mapstructure:"server"`
Log Log `mapstructure:"log"`
Postgres Postgres `mapstructure:"postgres"`
Redis Redis `mapstructure:"redis"`
Cache Cache `mapstructure:"cache"`
Session Session `mapstructure:"session"`
Env string `mapstructure:"env" validate:"omitempty,eq=dev"`
Server Server `mapstructure:"server"`
Log Log `mapstructure:"log"`
Postgres Postgres `mapstructure:"postgres"`
Redis Redis `mapstructure:"redis"`
Cache Cache `mapstructure:"cache"`
Session Session `mapstructure:"session"`
Idempotency Idempotency `mapstructure:"idempotency"`
}
type Session struct {
TTLSeconds int `mapstructure:"ttl_seconds" validate:"required,gt=0"`
}
// Idempotency holds the retention window of a message Idempotency-Key (contract
// 1.3.0 requires at least 24 hours).
type Idempotency struct {
TTLSeconds int `mapstructure:"ttl_seconds" validate:"required,gt=0"`
}
type Redis struct {
Enabled bool `mapstructure:"enabled"`
Host string `mapstructure:"host" validate:"omitempty,hostname|ip"`
@@ -66,6 +73,9 @@ type Server struct {
Port int `mapstructure:"port" validate:"required,min=1,max=65535"`
ReadHeaderTimeout time.Duration `mapstructure:"read_header_timeout" validate:"required,gt=0"`
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" validate:"required,gt=0"`
// MaxBodyBytes bounds a request body before the transport decodes it; uploads
// of a later lab raise it explicitly (contract 4: 10 MiB attachments).
MaxBodyBytes int64 `mapstructure:"max_body_bytes" validate:"required,gt=0"`
}
type Log struct {
@@ -114,9 +124,11 @@ var defaults = map[string]any{
"server.port": 8080,
"server.read_header_timeout": "10s",
"server.shutdown_timeout": "10s",
"server.max_body_bytes": 262144,
"log.level": "info",
"log.format": "json",
"session.ttl_seconds": 3600,
"idempotency.ttl_seconds": 86400,
"redis.enabled": false,
"redis.host": "localhost",
"redis.port": 6379,