From 680c624079f3f59ba82a97c375a33ea54c18d85d Mon Sep 17 00:00:00 2001 From: Jerome Amon Date: Mon, 13 Nov 2023 01:35:43 +0100 Subject: [PATCH] feat(configs): add settings for long request processing and response writing timeout --- config.go | 18 ++++++++++-------- config.yml | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config.go b/config.go index 601676f..c2ba069 100644 --- a/config.go +++ b/config.go @@ -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 { diff --git a/config.yml b/config.yml index cd9eedf..1a45540 100644 --- a/config.yml +++ b/config.yml @@ -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"