Skip to content

refactor(http): unify timeouts options across http client - #1600

Merged
tkan145 merged 1 commit into
3scale:masterfrom
tkan145:refactor-http-timeouts-interface
Aug 25, 2026
Merged

refactor(http): unify timeouts options across http client#1600
tkan145 merged 1 commit into
3scale:masterfrom
tkan145:refactor-http-timeouts-interface

Conversation

@tkan145

@tkan145 tkan145 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What

Previously the timeout configuration is awkwardly nested inside proxy_options. This commit extract timeout to top level, the interface now become

options = {
    timeout = {
        connect_timeout = 5,
        read_timeout = 5,
        write_timeout = 5,
    }
}

This is to prepare for THREESCALE-8006

Verification steps

  • Checkout this branch
  • Build new runtime-image
make runtime-image IMAGE_NAME=apicast-test
  • Get into dev-environment
cd dev-environments/https-proxy-upstream-tlsv1.3
  • Generate certs
make certs
  • Modify the apicast-config.json as follow
diff --git a/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json b/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json
index 5227c5aa..f0d70dd3 100644                                                                                                                   
--- a/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json                                                                           
+++ b/dev-environments/https-proxy-upstream-tlsv1.3/apicast-config.json                                                                           
@@ -5,7 +5,7 @@                                                                                                                                   
       "backend_version": "1",                                                                                                                    
       "proxy": {                                                                                                                                 
         "hosts": ["get.example.com"],                                                                                                            
-        "api_backend": "https://example.com/get",
+        "api_backend": "https://httpbingo.org",
         "backend": {                                                                                                                             
           "endpoint": "http://127.0.0.1:8081",                                                                                                   
           "host": "backend"                                                                                                                      
@@ -17,6 +17,14 @@                                                                                                                                
               "https_proxy": "http://proxy:443/"                                                                                                 
             }                                                                                                                                    
           },                                                                                                                                     
+          {
+            "name": "apicast.policy.upstream_connection",
+            "configuration": {
+              "connect_timeout": 1,
+              "send_timeout": 1,
+              "read_timeout": 1
+            } 
+          },
           {                                                                                                                                      
             "name": "apicast.policy.apicast"                                                                                                     
           }                                                                                                
  • Start the gateway
make gateway IMAGE_NAME=apicast-test
  • Send a first request
curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/get?user_key=123"
  • Send a second request with delay, you should see the upstream_connection policy timeout kicked in
curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/delay/3?user_key=123"

....
<html>                                     
<head><title>502 Bad Gateway</title></head>
<body>                                     
<center><h1>502 Bad Gateway</h1></center>  
</body>                                    
</html>                                           

@tkan145
tkan145 requested a review from a team as a code owner August 24, 2026 04:20
@tkan145
tkan145 force-pushed the refactor-http-timeouts-interface branch from 59b36bb to 34aa7b7 Compare August 24, 2026 04:34
@tkan145
tkan145 force-pushed the refactor-http-timeouts-interface branch from 34aa7b7 to 4028829 Compare August 25, 2026 02:14
Previously the timeout configuration is awkwardly nested inside
proxy_options. This commit extract timeout to top level, the interface
now become

options = {
    timeout = {
        connect_timeout = 5,
        read_timeout = 5,
        write_timeout = 5,
    }
}
@tkan145
tkan145 force-pushed the refactor-http-timeouts-interface branch from 4028829 to b73feab Compare August 25, 2026 03:51
@tkan145
tkan145 merged commit 1b0032e into 3scale:master Aug 25, 2026
13 checks passed
@tkan145
tkan145 deleted the refactor-http-timeouts-interface branch August 25, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants