-
Notifications
You must be signed in to change notification settings - Fork 26
HTTP fanout error logic
The source which implements the fanout error translation is in the fanouthttp package. This is the error translation logic used by scytale
.
A fanout consists of one or more configured endpoints. Each endpoint is a full URL and can include path information as well as host and port.
From the point of view of a consumer of http.Client
, a single, logical HTTP transaction occurs for each configured fanout endpoint. This logical HTTP transaction may be composed of any number of redirects. This would be the case when a fanout endpoint refers to petasos
.
There are two timeouts relevant to fanout processing.
First, each endpoint has an endpoint timeout
. If any endpoint's HTTP transaction does not complete within the endpoint timeout
, that transaction is abandoned and no status code is associated with it.
Second, there is a fanout timeout
that applies to the entire operation. If the fanout timeout
elapses without any endpoint returning, the operation is considered to have timed out. Obviously, the fanout timeout
should be larger than the endpoint timeout
.
- If any endpoint returns a 2XX status code within the
fanout timeout
, that status code is returned. Any inflight transactions to other endpoints are abandoned. Any fanout transactions that completed with non-2XX status codes are ignored. - If all endpoints return status codes, and no status is in the 5XX block, then the highest status code is returned. For example, given that there are only (2) endpoints: if one endpoint returns a
404
and another endpoint returns a400
,404
is returned to the caller. - If all endpoints return status codes, and there is at least (1) status code in the 5XX block, then
503
is returned. - Finally, if all endpoints timeout, or the
fanout timeout
elapses,504
is returned.