php editor Apple brings you an introduction to KrakenD sequential endpoint error response. KrakenD is a high-performance API gateway, but you may encounter some errors during use. Among them, sequential endpoint error response is a common problem. This article will explain in detail the causes and solutions of sequential endpoint error responses to help you better deal with this problem and improve the stability and performance of the API gateway.
krakend version: 2.2.1 go version: go1.19.3
I want to use krakend's sequential functionality to send sequential requests to two different endpoints.
Briefly summarize my case:
Sequential endpoint example:
{ "endpoint": "/companies/validate", "method": "GET", {{ include "input_headers.txt" }}, "backend": [ { "host": ["{{ .service.credential_service_url }}"], "url_pattern": "/tokens/validate", "method": "GET", "extra_config": { "backend/http": { "return_error_code": true } } }, { "host": ["{{ .service.company_service_url }}"], "url_pattern": "/companies/{resp0_companyId}/validate", "method": "GET", "extra_config": { "backend/http": { "return_error_code": true } } } ], "extra_config": { "proxy": { "sequential": true } } }
ide log
Postman Reply
As you can see, the first service works fine and the second service returns an error, but the postman response returns success.
This is expected behavior of KrakenD.
When you make multiple calls, KrakenD will return whatever is available along with a 200 status code if at least one request succeeds. But in exchange, you get a header X-KrakenD-Complete: false
telling you that something failed. You can read more about aggregation here p>
Since you are using a sequential proxy, when the first request fails, there is no need to do anything else as the next sequential call will automatically abort. So everything fails and KrakenD can't return anything, which is why you get the failure you want.
In the other case, KrakenD has something to return since the first call worked, and you receive partial data.
You should examine the contents of your client's X-KrakenD-Complete header to decide what to do
The above is the detailed content of KrakenD sequential endpoint error response. For more information, please follow other related articles on the PHP Chinese website!