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

EES-4879 Adding a blanket 30s timeout across all Public API endpoints #5137

Merged
merged 7 commits into from
Aug 21, 2024

Conversation

jack-hive
Copy link
Collaborator

This PR adds a 30 second 504 timeout to all Public API endpoints.

We also have a change to document these 504 timeout responses in the swagger documentation across all endpoints.

options.DefaultPolicy =
new RequestTimeoutPolicy
{
Timeout = TimeSpan.FromMilliseconds(30000),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't knwo if it's worth making this configurable (with a 30s fallback), and set to something like 500ms in our integration tests? That way, we can register a test controller that delays for 1s and then we can test the response.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I'll make that change!

@@ -19,5 +19,6 @@
},
"DataFiles": {
"BasePath": "data/public-api-data"
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess with the fallback, you don't really need this value here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No that's true! I thought I'd leave it there for discoverability. But I'll remove it :)

@jack-hive jack-hive force-pushed the EES-4879 branch 3 times, most recently from 0aa941d to 8843c42 Compare August 19, 2024 10:46
options.DefaultPolicy =
new RequestTimeoutPolicy
{
Timeout = TimeSpan.FromMilliseconds(configuration.GetValue<int?>("RequestTimeoutMilliseconds") ?? 30000),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good for us to extract out an AppSettingsOptions class to house this configuration. We already do this in other parts of the service and would give some type-safety over this.

This could then be re-used in the tests as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking of doing this, but then thought since it's just a one-off setting and I couldn't envisage us nesting any other options beneath the 'timeout' section as such, I thought I'd just simplify it by removing the need for the extra class. But I agree, it might be slightly better to do this. I've made a change :)

Comment on lines 3 to 7
public class RequestTimeoutOptions
{
public const string Section = "RequestTimeouts";

public int? RequestTimeoutMilliseconds { get; init; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given we've opted to put this in a RequestTimeout section, we could simplify this key to just TimeoutMilliseconds.

I was also wondering if you could just put the default value (30000) in here as well? That way we don't need to put the default in Startup. Not entirely sure if this works as we'd expect or not though (would suggest checking).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed :)

I tested the default, but it doesn't work unfortunately :(


public class RequestTimeoutOptions
{
public const string Section = "RequestTimeouts";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be RequestTimeout to align with the class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done :)

Copy link
Collaborator

@ntsim ntsim left a comment

Choose a reason for hiding this comment

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

There are currently some build errors that need to be fixed

@jack-hive
Copy link
Collaborator Author

There are currently some build errors that need to be fixed

I have no idea how this happened. I'm pretty sure I used F2 to rename the variable everywhere!. But my Visual Studio has been playing up a lot lately with detecting renames. I might have to get into the habit of running tests again even after something as simple as a rename :P

@jack-hive jack-hive added the do not merge Don't merge just yet label Aug 20, 2024
@jack-hive jack-hive merged commit 5295c98 into dev Aug 21, 2024
7 checks passed
@jack-hive jack-hive deleted the EES-4879 branch August 21, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Don't merge just yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants