[PHASE-6] Define server configuration

This commit is contained in:
Savely Krendelhoff 2025-08-23 12:46:17 +07:00
parent 9d10f385b5
commit 8476340f75
No known key found for this signature in database
GPG key ID: F70DFD34F40238DE

31
internal/server/config.go Normal file
View file

@ -0,0 +1,31 @@
package server
import "time"
// Config holds configuration for the TCP server
type Config struct {
Address string
Timeouts TimeoutConfig
}
// TimeoutConfig holds timeout configuration
type TimeoutConfig struct {
// Read timeout protects against slowloris attacks (clients sending data slowly)
Read time.Duration
// Write timeout protects against slow readers (clients reading responses slowly)
Write time.Duration
// Connection timeout is the maximum total connection lifetime
Connection time.Duration
}
// DefaultConfig returns default server configuration
func DefaultConfig() *Config {
return &Config{
Address: ":8080",
Timeouts: TimeoutConfig{
Read: 5 * time.Second,
Write: 5 * time.Second,
Connection: 15 * time.Second,
},
}
}