-
Notifications
You must be signed in to change notification settings - Fork 528
Rename request body min rate APIs (#1901) #1915
Conversation
b18c827
to
b194c9b
Compare
public MinimumDataRate RequestBodyMinimumDataRate { get; set; } = new MinimumDataRate(rate: 1, gracePeriod: TimeSpan.FromSeconds(5)); | ||
public MinimumDataRate MinRequestBodyDataRate { get; } = new MinimumDataRate { BytesPerSecond = 1, GracePeriod = TimeSpan.FromSeconds(5) }; | ||
|
||
public class MinimumDataRate |
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 like having a public nested 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.
The feature uses two fields but the options use a custom type? Why is this type needed for options?
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.
@Tratcher MinRequestBodyDataRate.BytesPerSecond
matches how the feature is used better than MinRequestBodyDataRateBytesPerSecond
. It's just aesthetics though.
get => _gracePeriod; | ||
set | ||
{ | ||
if (value < TimeSpan.Zero) |
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 wonder if we should throw for TimeSpan.Zero too, since that's just asking for problems.
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.
It's still a legal value. Means the rate will be enforced right away. It's not recommended, but there's no technical reason to disallow it.
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.
The technical reason to disallow it is because setting it to zero creates a race that could cause any connection to be killed no matter the actual upload rate
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.
Then we should require it to be larger than 1 second.
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.
Or, more precisely, larger than Heartbeat.Interval
, which right now is one second.
get => MinRequestBodyDataRate.GracePeriod; | ||
set | ||
{ | ||
if (value < TimeSpan.Zero) |
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.
Is there a way to share the validation logic between this and the MinimumDataRate class?
double BytesPerSecond { get; set; } | ||
|
||
/// <summary> | ||
/// The amount of time to delay enforcement of the minimum data rate. |
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.
Starting from when? After the request arrives? The first read?
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.
Will add ", starting at the time data is first read or written." Written as well since this same type will (likely) be used for the response rate.
public MinimumDataRate RequestBodyMinimumDataRate { get; set; } = new MinimumDataRate(rate: 1, gracePeriod: TimeSpan.FromSeconds(5)); | ||
public MinimumDataRate MinRequestBodyDataRate { get; } = new MinimumDataRate { BytesPerSecond = 1, GracePeriod = TimeSpan.FromSeconds(5) }; | ||
|
||
public class MinimumDataRate |
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.
The feature uses two fields but the options use a custom type? Why is this type needed for options?
|
778a6a6
to
524fb68
Compare
📢 |
@@ -6,7 +6,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Features | |||
/// <summary> | |||
/// Represents a minimum data rate for the request body of an HTTP request. | |||
/// </summary> | |||
public interface IHttpRequestBodyMinimumDataRateFeature | |||
public interface IHttpMinRequestBodyDataRateFeature |
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'm not sure we should be abbreviating Minimum to Min
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.
After thinking about this for a little bit, I think we should change all usages of "Minimum" in public APIs to "Min" for consistency considering how many limits already use "Max".
So that means the MinimumDataRate class changes to MinDataRate, IHttpMinRequestBodyDataRateFeature.MinimumDataRate changes to IHttpMinRequestBodyDataRateFeature.MinDataRate, etc...
I don't care as much about private/internal names, but I think some of that could also change to match.
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 already change the property/param to bytesPerSecond, so that's taken care of. I'll change the type name now.
I went with Min because we already have Max on other properties.
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.
+1 for MinDataRate over MinimumDataRate. It's more consistent. All other changes look fine to me.
I meant to leave a comment with my approval. I approve this pending changing "Minimum" to "Min" in all public APIs. |
Updated, will merge when CI is green. |
/// </summary> | ||
/// <remarks> | ||
/// Defaults to 1 byte/second with a 5 second grace period. | ||
/// </remarks> | ||
public MinimumDataRate RequestBodyMinimumDataRate { get; set; } = new MinimumDataRate(rate: 1, gracePeriod: TimeSpan.FromSeconds(5)); | ||
public MinDataRate MinRequestBodyDataRate { get; set; } = new MinDataRate(bytesPerSecond: 1, gracePeriod: TimeSpan.FromSeconds(5)); |
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.
Change this to match the IIS default. I believe it's 240 bytes/second.
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.
Separate change. Let's discuss it in the office tomorrow.
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.
And here I was trying to avoid creating a new issue 😢
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 know I already approved this. Hopeful changing the default is the last thing. |
#1901