Skip to content
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

APPSRE-7875: Add request timeout handler #57

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

kwilczynski
Copy link
Contributor

@kwilczynski kwilczynski commented Jul 7, 2023

Currently, the total time allotted for the lifespan of the request is controlled through the WriteTimeout property of the http.Server type, which is used to configure the server listener.

However, this timeout is not only currently not working as intended (see the following list of issues), and there is also no way to propagate cancellation using Context properly - so that the SQL query can be cancelled on client disconnection or when the request timeout is reached.

The list of currently open WriteTimeout-related issues:

Thus, add a middleware, called Timeout, that provides request timeout support and can be used to expire the execution of the subsequent handler in the chain. Also, make sure that the QueryContext() function is used to propagate the cancellation correctly.

The timeout can be controlled via an environment variable called REQUEST_TIMEOUT; the default is two minutes.

While at it, upgrade the PostgreSQL driver and Red Hat's fork of OAuth2 Proxy to the latest stable releases.

Related: APPSRE-7875

Signed-off-by: Krzysztof Wilczyński [email protected]

@kwilczynski kwilczynski added the enhancement New feature or request label Jul 7, 2023
@kwilczynski kwilczynski self-assigned this Jul 7, 2023
@kwilczynski kwilczynski force-pushed the feature/add-timeout-handler branch 12 times, most recently from ac313fa to 8becc9c Compare July 9, 2023 16:41
go.mod Show resolved Hide resolved
@kwilczynski kwilczynski marked this pull request as ready for review July 9, 2023 17:54
Signed-off-by: Krzysztof Wilczyński <[email protected]>
@kwilczynski kwilczynski force-pushed the feature/add-timeout-handler branch from 8becc9c to 14ca4b4 Compare July 9, 2023 17:57
Copy link

@geoberle geoberle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants