-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
options.DefaultPolicy = | ||
new RequestTimeoutPolicy | ||
{ | ||
Timeout = TimeSpan.FromMilliseconds(30000), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" | |||
} | |||
}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
0aa941d
to
8843c42
Compare
options.DefaultPolicy = | ||
new RequestTimeoutPolicy | ||
{ | ||
Timeout = TimeSpan.FromMilliseconds(configuration.GetValue<int?>("RequestTimeoutMilliseconds") ?? 30000), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
public class RequestTimeoutOptions | ||
{ | ||
public const string Section = "RequestTimeouts"; | ||
|
||
public int? RequestTimeoutMilliseconds { get; init; } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :)
There was a problem hiding this 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
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 |
…n't affect the other tests
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.