Skip to content

Commit

Permalink
feat(configs): add settings for long request processing and response …
Browse files Browse the repository at this point in the history
…writing timeout
  • Loading branch information
jeamon committed Nov 13, 2023
1 parent b7a2265 commit 680c624
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ type Config struct {
}

type ServerConfig struct {
Host string `yaml:"host" envconfig:"DRAP_SERVER_HOST"`
Port string `yaml:"port" envconfig:"DRAP_SERVER_PORT"`
CertsFile string `yaml:"certs_file" envconfig:"DRAP_SERVER_CERTS_FILE"`
KeyFile string `yaml:"key_file" envconfig:"DRAP_SERVER_KEY_FILE"`
ReadTimeout time.Duration `yaml:"read_timeout" envconfig:"DRAP_SERVER_READ_TIMEOUT"`
WriteTimeout time.Duration `yaml:"write_timeout" envconfig:"DRAP_SERVER_WRITE_TIMEOUT"`
RequestTimeout time.Duration `yaml:"request_timeout" envconfig:"DRAP_SERVER_REQUEST_TIMEOUT"` // Time to wait for a request to finish
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" envconfig:"DRAP_SERVER_SHUTDOWN_TIMEOUT"`
Host string `yaml:"host" envconfig:"DRAP_SERVER_HOST"`
Port string `yaml:"port" envconfig:"DRAP_SERVER_PORT"`
CertsFile string `yaml:"certs_file" envconfig:"DRAP_SERVER_CERTS_FILE"`
KeyFile string `yaml:"key_file" envconfig:"DRAP_SERVER_KEY_FILE"`
ReadTimeout time.Duration `yaml:"read_timeout" envconfig:"DRAP_SERVER_READ_TIMEOUT"`
WriteTimeout time.Duration `yaml:"write_timeout" envconfig:"DRAP_SERVER_WRITE_TIMEOUT"`
LongRequestProcessingTimeout time.Duration `yaml:"long_request_processing_timeout" envconfig:"DRAP_SERVER_LONG_REQUEST_PROCESSING_TIMEOUT"`
LongRequestWriteTimeout time.Duration `yaml:"long_request_write_timeout" envconfig:"DRAP_SERVER_LONG_REQUEST_WRITE_TIMEOUT"`
RequestTimeout time.Duration `yaml:"request_timeout" envconfig:"DRAP_SERVER_REQUEST_TIMEOUT"` // Time to wait for a request to finish
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" envconfig:"DRAP_SERVER_SHUTDOWN_TIMEOUT"`
}

type RedisConfig struct {
Expand Down
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ server:
# timeout message to be sent.
write_timeout: 17s
request_timeout: 15s
# long request like GET /v1/books
# use http.ResponseController to set
long_request_processing_timeout: 55s
long_request_write_timeout: 60s
shutdown_timeout: 90s
certs_file: "./server.crt"
key_file: "./server.key"
Expand Down

0 comments on commit 680c624

Please sign in to comment.