[PHASE-6] Define server configuration
This commit is contained in:
parent
9d10f385b5
commit
8476340f75
31
internal/server/config.go
Normal file
31
internal/server/config.go
Normal 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,
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue