When a request to a service takes a long time, there is currently no way for the service to signal back to the resgate that the request has been received and is being worked on. This may cause the request to timeout, giving the client a timeout error, even if the request has been processed.
Suggested solution
A meta response may be made by the service to any type of request. This response would contain the new desired timeout duration in milliseconds. To be easy to distinguish from the actual json response, it should not be json encoded.
It should be utf-8/latin-1 encoded and have the format timeout:"<number>". These sort of meta responses may later be extended with more key/values, using comma separation. resgate can quickly detect a meta response by analyzing the first byte - if it is a latin-1 letter, it is a meta response.
Example meta response, extending the timeout to 10 seconds:
Modified the format from:
timeout:
to
timeout:""
This allowed using reflect.StructTag parsing, as well as being more flexible in case new keys are added.
Issue
When a request to a service takes a long time, there is currently no way for the service to signal back to the resgate that the request has been received and is being worked on. This may cause the request to timeout, giving the client a timeout error, even if the request has been processed.
Suggested solution
A meta response may be made by the service to any type of request. This response would contain the new desired timeout duration in milliseconds. To be easy to distinguish from the actual json response, it should not be json encoded.
It should be utf-8/latin-1 encoded and have the format
timeout:"<number>"
. These sort of meta responses may later be extended with more key/values, using comma separation. resgate can quickly detect a meta response by analyzing the first byte - if it is a latin-1 letter, it is a meta response.Example meta response, extending the timeout to 10 seconds: