1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-03-08 15:21:13 +02:00

Rename IMGPROXY_WRITE_TIMEOUT to IMGPROXY_TIMEOUT and IMGPROXY_READ_TIMEOUT to IMGPROXY_READ_REQUEST_TIMEOUT

This commit is contained in:
DarthSim 2024-06-03 20:36:32 +03:00
parent e867d0f10a
commit cb32e71788
4 changed files with 34 additions and 13 deletions

View File

@ -10,6 +10,8 @@
### Changed ### Changed
- Automatically add `http://` scheme to the `IMGPROXY_S3_ENDPOINT` value if it has no scheme. - Automatically add `http://` scheme to the `IMGPROXY_S3_ENDPOINT` value if it has no scheme.
- Trim redundant slashes in the S3 object key. - Trim redundant slashes in the S3 object key.
- Rename `IMGPROXY_WRITE_TIMEOUT` to `IMGPROXY_TIMEOUT`. The old name is deprecated but still supported.
- Rename `IMGPROXY_READ_TIMEOUT` to `IMGPROXY_READ_REQUEST_TIMEOUT`. The old name is deprecated but still supported.
- (pro) Allow specifying [gradient](https://docs.imgproxy.net/latest/usage/processing#gradient) direction as an angle in degrees. - (pro) Allow specifying [gradient](https://docs.imgproxy.net/latest/usage/processing#gradient) direction as an angle in degrees.
### Fix ### Fix
@ -18,6 +20,10 @@
- (pro) Fix style injection to SVG. - (pro) Fix style injection to SVG.
- (pro) Fix video tiles generation when the video's SAR is not `1`. - (pro) Fix video tiles generation when the video's SAR is not `1`.
### Deprecated
- `IMGPROXY_WRITE_TIMEOUT` config is deprecated. Use `IMGPROXY_TIMEOUT` instead.
- `IMGPROXY_READ_TIMEOUT` config is deprecated. Use `IMGPROXY_READ_REQUEST_TIMEOUT` instead.
## [3.24.1] - 2024-04-30 ## [3.24.1] - 2024-04-30
### Fix ### Fix
- Fix the default `IMGPROXY_WORKERS` value when cgroup limits are applied. - Fix the default `IMGPROXY_WORKERS` value when cgroup limits are applied.

View File

@ -21,8 +21,8 @@ type URLReplacement = configurators.URLReplacement
var ( var (
Network string Network string
Bind string Bind string
ReadTimeout int Timeout int
WriteTimeout int ReadRequestTimeout int
WriteResponseTimeout int WriteResponseTimeout int
KeepAliveTimeout int KeepAliveTimeout int
ClientKeepAliveTimeout int ClientKeepAliveTimeout int
@ -217,8 +217,8 @@ func init() {
func Reset() { func Reset() {
Network = "tcp" Network = "tcp"
Bind = ":8080" Bind = ":8080"
ReadTimeout = 10 Timeout = 10
WriteTimeout = 10 ReadRequestTimeout = 10
WriteResponseTimeout = 10 WriteResponseTimeout = 10
KeepAliveTimeout = 10 KeepAliveTimeout = 10
ClientKeepAliveTimeout = 90 ClientKeepAliveTimeout = 90
@ -403,11 +403,24 @@ func Configure() error {
configurators.String(&Network, "IMGPROXY_NETWORK") configurators.String(&Network, "IMGPROXY_NETWORK")
configurators.String(&Bind, "IMGPROXY_BIND") configurators.String(&Bind, "IMGPROXY_BIND")
configurators.Int(&ReadTimeout, "IMGPROXY_READ_TIMEOUT")
configurators.Int(&WriteTimeout, "IMGPROXY_WRITE_TIMEOUT") if _, ok := os.LookupEnv("IMGPROXY_WRITE_TIMEOUT"); ok {
log.Warning("IMGPROXY_WRITE_TIMEOUT is deprecated, use IMGPROXY_TIMEOUT instead")
configurators.Int(&Timeout, "IMGPROXY_WRITE_TIMEOUT")
}
configurators.Int(&Timeout, "IMGPROXY_TIMEOUT")
if _, ok := os.LookupEnv("IMGPROXY_READ_TIMEOUT"); ok {
log.Warning("IMGPROXY_READ_TIMEOUT is deprecated, use IMGPROXY_READ_REQUEST_TIMEOUT instead")
configurators.Int(&ReadRequestTimeout, "IMGPROXY_READ_TIMEOUT")
}
configurators.Int(&ReadRequestTimeout, "IMGPROXY_READ_REQUEST_TIMEOUT")
configurators.Int(&WriteResponseTimeout, "IMGPROXY_WRITE_RESPONSE_TIMEOUT") configurators.Int(&WriteResponseTimeout, "IMGPROXY_WRITE_RESPONSE_TIMEOUT")
configurators.Int(&KeepAliveTimeout, "IMGPROXY_KEEP_ALIVE_TIMEOUT") configurators.Int(&KeepAliveTimeout, "IMGPROXY_KEEP_ALIVE_TIMEOUT")
configurators.Int(&ClientKeepAliveTimeout, "IMGPROXY_CLIENT_KEEP_ALIVE_TIMEOUT") configurators.Int(&ClientKeepAliveTimeout, "IMGPROXY_CLIENT_KEEP_ALIVE_TIMEOUT")
configurators.Int(&DownloadTimeout, "IMGPROXY_DOWNLOAD_TIMEOUT") configurators.Int(&DownloadTimeout, "IMGPROXY_DOWNLOAD_TIMEOUT")
if lambdaFn := os.Getenv("AWS_LAMBDA_FUNCTION_NAME"); len(lambdaFn) > 0 { if lambdaFn := os.Getenv("AWS_LAMBDA_FUNCTION_NAME"); len(lambdaFn) > 0 {
@ -627,12 +640,14 @@ func Configure() error {
return errors.New("Bind address is not defined") return errors.New("Bind address is not defined")
} }
if ReadTimeout <= 0 { if Timeout <= 0 {
return fmt.Errorf("Read timeout should be greater than 0, now - %d\n", ReadTimeout) return fmt.Errorf("Timeout should be greater than 0, now - %d\n", Timeout)
} }
if ReadRequestTimeout <= 0 {
if WriteTimeout <= 0 { return fmt.Errorf("Read request timeout should be greater than 0, now - %d\n", ReadRequestTimeout)
return fmt.Errorf("Write timeout should be greater than 0, now - %d\n", WriteTimeout) }
if WriteResponseTimeout <= 0 {
return fmt.Errorf("Write response timeout should be greater than 0, now - %d\n", WriteResponseTimeout)
} }
if KeepAliveTimeout < 0 { if KeepAliveTimeout < 0 {
return fmt.Errorf("KeepAlive timeout should be greater than or equal to 0, now - %d\n", KeepAliveTimeout) return fmt.Errorf("KeepAlive timeout should be greater than or equal to 0, now - %d\n", KeepAliveTimeout)

View File

@ -15,7 +15,7 @@ type timerSinceCtxKey = struct{}
func startRequestTimer(r *http.Request) (*http.Request, context.CancelFunc) { func startRequestTimer(r *http.Request) (*http.Request, context.CancelFunc) {
ctx := r.Context() ctx := r.Context()
ctx = context.WithValue(ctx, timerSinceCtxKey{}, time.Now()) ctx = context.WithValue(ctx, timerSinceCtxKey{}, time.Now())
ctx, cancel := context.WithTimeout(ctx, time.Duration(config.WriteTimeout)*time.Second) ctx, cancel := context.WithTimeout(ctx, time.Duration(config.Timeout)*time.Second)
return r.WithContext(ctx), cancel return r.WithContext(ctx), cancel
} }

View File

@ -59,7 +59,7 @@ func startServer(cancel context.CancelFunc) (*http.Server, error) {
s := &http.Server{ s := &http.Server{
Handler: buildRouter(), Handler: buildRouter(),
ReadTimeout: time.Duration(config.ReadTimeout) * time.Second, ReadTimeout: time.Duration(config.ReadRequestTimeout) * time.Second,
MaxHeaderBytes: 1 << 20, MaxHeaderBytes: 1 << 20,
ErrorLog: errLogger, ErrorLog: errLogger,
} }