-
Notifications
You must be signed in to change notification settings - Fork 172
[THREESCALE-9542] Part 1: buffering policy #1408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tkan145
merged 6 commits into
3scale:master
from
tkan145:THREESCALE-9542-buffering-policy
Nov 27, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d05940
Extract @upstream content to a seperate file
tkan145 204d483
Add new @upstream blocks for unbuffered request
tkan145 110522c
Introduce request_unbuffered policy
tkan145 c1a7cac
Add README file
tkan145 26edbf7
Update CHANGELOG
tkan145 5bda7fc
Correct the integration test
tkan145 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #{% capture proxy_cache_valid %} | ||
| #{#} proxy_cache $cache_zone; | ||
| #{#} proxy_cache_key $scheme$request_method$proxy_host$request_uri$service_id; | ||
| #{#} proxy_no_cache $cache_request; | ||
| #{#} proxy_cache_valid {{ env.APICAST_CACHE_STATUS_CODES | default: '200 302'}} {{ env.APICAST_CACHE_MAX_TIME | default: '1m' }}; | ||
| #{% endcapture %} | ||
| #{{ proxy_cache_valid | replace: "#{#}", "" }} | ||
| # | ||
|
|
||
| #{% if opentelemetry != empty %} | ||
| # {% capture opentelemetry_propagate_directive %} | ||
| #{#} opentelemetry_propagate; | ||
| # {% endcapture %} | ||
| # {{ opentelemetry_propagate_directive | replace: "#{#}", "" }} | ||
| #{% endif %} | ||
|
|
||
| proxy_pass $proxy_pass; | ||
|
|
||
| proxy_http_version 1.1; | ||
|
|
||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header Host $http_host; | ||
| proxy_set_header X-3scale-proxy-secret-token $secret_token; | ||
| proxy_set_header X-3scale-debug ""; | ||
| proxy_set_header Connection $upstream_connection_header; | ||
| proxy_set_header Upgrade $upstream_upgrade_header; | ||
|
|
||
| # This is a bit tricky. It uses liquid to set a SSL client certificate. In | ||
| # NGINX, all this is not executed as it is commented with '#'. However, in | ||
| # Liquid, all this will be evaluated. As a result, the following directives | ||
| # are set optionally: proxy_ssl_certificate, proxy_ssl_certificate_key, | ||
| # proxy_ssl_session_reuse, and proxy_ssl_password_file. | ||
|
|
||
| # {% if proxy_ssl_certificate != empty and proxy_ssl_certificate_key != empty %} | ||
| # {% capture proxy_ssl %} | ||
| #{#} proxy_ssl_certificate {{ proxy_ssl_certificate }}; | ||
| #{#} proxy_ssl_certificate_key {{ proxy_ssl_certificate_key }}; | ||
| # {% endcapture %} | ||
| # {{ proxy_ssl | replace: "#{#}", "" }} | ||
| # | ||
| # {% if proxy_ssl_password_file != empty %} | ||
| # {% capture proxy_ssl %} | ||
| #{#} proxy_ssl_password_file {{ proxy_ssl_password_file }}; | ||
| # {% endcapture %} | ||
| # {{ proxy_ssl | replace: "#{#}", "" }} | ||
| # {% endif %} | ||
| # | ||
| # {% if proxy_ssl_session_reuse != empty %} | ||
| # {% capture proxy_ssl %} | ||
| #{#} proxy_ssl_session_reuse {{ proxy_ssl_session_reuse }}; | ||
| # {% endcapture %} | ||
| # {{ proxy_ssl | replace: "#{#}", "" }} | ||
| # {% endif %} | ||
| # {% endif %} | ||
|
|
||
| # When 'upstream_retry_cases' is empty, apply the same default as NGINX. | ||
| # If the proxy_next_upstream directive is not declared, the retry policy | ||
| # will never retry. | ||
| # {% if upstream_retry_cases != empty %} | ||
| # {% capture proxy_next_upstream %} | ||
| #{#} proxy_next_upstream {{ upstream_retry_cases }}; | ||
| # {% endcapture %} | ||
| # {{ proxy_next_upstream | replace: "#{#}", "" }} | ||
| # {% else %} | ||
| # proxy_next_upstream error timeout; | ||
| # {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # APICast Request Unbuffered | ||
|
|
||
| This policy allows to disable request buffering | ||
|
|
||
| ## Example configuration | ||
|
|
||
| ``` | ||
| { | ||
| "name": "request_unbuffered", | ||
| "version": "builtin", | ||
| "configuration": {} | ||
| } | ||
| ``` | ||
|
|
13 changes: 13 additions & 0 deletions
13
gateway/src/apicast/policy/request_unbuffered/apicast-policy.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
| "name": "Request Unbuffered", | ||
| "summary": "Disable request buffering", | ||
| "description": [ | ||
| "Disable request buffering. This is useful when proxying big payloads with HTTP/1.1 chunked encoding" | ||
| ], | ||
| "version": "builtin", | ||
| "configuration": { | ||
| "type": "object", | ||
| "properties": {} | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| return require('request_unbuffered') |
22 changes: 22 additions & 0 deletions
22
gateway/src/apicast/policy/request_unbuffered/request_unbuffered.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| -- Request Unbuffered policy | ||
| -- This policy will disable request buffering | ||
|
|
||
| local policy = require('apicast.policy') | ||
| local _M = policy.new('request_unbuffered') | ||
|
|
||
| local new = _M.new | ||
|
|
||
| --- Initialize a buffering | ||
| -- @tparam[opt] table config Policy configuration. | ||
| function _M.new(config) | ||
| local self = new(config) | ||
| return self | ||
| end | ||
|
|
||
| function _M:export() | ||
| return { | ||
| request_unbuffered = true, | ||
| } | ||
| end | ||
|
|
||
| return _M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.