Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Rename min rate APIs for consistency #1901

Closed
cesarblum opened this issue Jun 15, 2017 · 10 comments
Closed

Rename min rate APIs for consistency #1901

cesarblum opened this issue Jun 15, 2017 · 10 comments
Assignees
Milestone

Comments

@cesarblum
Copy link
Contributor

We should do this before RTM:

  • Rename KestrelServerLimits.RequestBodyMinimumDataRate to MinRequestBodyDataRate (consistent with MaxRequestBodySize, and other limits that all start with “Max”)
  • Rename IHttpRequestBodyMinimumDataRateFeature to IHttpMinRequestBodyDataRateFeature (consistent with IHttpMaxRequestBodySizeFeature)
  • Rename the rate parameter of the MinimumDataRate ctor to bytesPerSecond, so that the rate’s unit of measurement is clear
@cesarblum
Copy link
Contributor Author

@muratg

@muratg muratg added this to the 2.0.0 milestone Jun 15, 2017
@muratg
Copy link
Contributor

muratg commented Jun 15, 2017

@Eilon @DamianEdwards @shirhatti FYI -- proposed breaking change between preview2 and RTM to make the names more consistent.

@Eilon
Copy link
Member

Eilon commented Jun 16, 2017

Can someone show the full list of before/after values? Hard to tell what's consistent etc.

@muratg
Copy link
Contributor

muratg commented Jun 16, 2017

@CesarBS could you make a table?

@cesarblum
Copy link
Contributor Author

KestrelServerLimits

Before After
MaxResponseBufferSize MaxResponseBufferSize
MaxRequestBufferSize MaxRequestBufferSize
MaxRequestLineSize MaxRequestLineSize
MaxRequestHeadersTotalSize MaxRequestHeadersTotalSize
MaxRequestHeaderCount MaxRequestHeaderCount
MaxRequestBodySize MaxRequestBodySize
RequestBodyMinimumDataRate MinRequestBodyDataRate
MaxConcurrentConnections MaxConcurrentConnections
MaxConcurrentUpgradedConnections MaxConcurrentUpgradedConnections
KeepAliveTimeout KeepAliveTimeout
RequestHeadersTimeout RequestHeadersTimeout

Features

Before After
IHttpMaxRequestBodySizeFeature IHttpMaxRequestBodySizeFeature
IHttpRequestBodyMinimumDataRateFeature IHttpMinRequestBodyDataRateFeature

MinimumDataRate

Before

public class MinimumDataRate
{
    public MinimumDataRate(double rate, TimeSpan gracePeriod)
    {
        ...
    }

    public double Rate { get; }

    public TimeSpan GracePeriod { get; }
}

After

public class MinimumDataRate
{
    public MinimumDataRate(double bytesPerSecond, TimeSpan gracePeriod)
    {
        ...
    }

    public double BytesPerSecond { get; }

    public TimeSpan GracePeriod { get; }
}

@dougbu
Copy link
Member

dougbu commented Jun 18, 2017

I suggest we also look at MinimumDataRate's usability. Configuring rates requires newing up an instance and its Microsoft.AspNetCore.Server.Kestrel.Core.Features namespace is obscure, increasing the number of usings in Program and/or Startup classes.

Could either move MinimumDataRate' to a common namespace e.g. Microsoft.AspNetCore.Hosting or make the BytesPerSecond and GracePeriod properties settable and lazy-load MinRequestBodyDataRate in KestrelServerLimits and IHttpMinRequestBodyDataRateFeature. The settable / lazy-load option has the advantage of reducing the boilerplate users write.

E.g. current default setting:

using Microsoft.AspNetCore.Server.Kestrel.Core.Features;

    var dataRate = new MinimumDataRate(rate: 100, gracePeriod: TimeSpan.FromSeconds(2));
    limits.RequestBodyMinimumDataRate = dataRate;

Proposed new default setting, second alternative:

    limits.RequestBodyMinimumDataRate.BytesPerSecond = 100;
    // Perhaps optional. Would probably need a reasonable default for `GracePeriod` anyway.
    limits.RequestBodyMinimumDataRate.GracePeriod = TimeSpan.FromSeconds(2);

@cesarblum
Copy link
Contributor Author

When we had the discussion about having a MinimumDataRate type, it was because there was an additional property in the feature and we wanted to make it clear that the two properties related to the rate should belong together.

But now that it's just the rate, we should remove MinimumDataRate from the feature and just put the properties in the feature itself, and change KestrelServerLimits like @dougbu is suggesting.

@cesarblum
Copy link
Contributor Author

Should also make IHttpMinRequestBodyDataRate configurable only prior to any reads, for parity with how IHttpMinRequestBodySize works.

@Eilon
Copy link
Member

Eilon commented Jun 20, 2017

I'm not sure we need to worry much about how many namespaces are imported for a very obscure server feature. The importance of this feature is that it exists and has smart defaults. For the few people in the world who would override the defaults, I'm not concerned how many namespace they import. VS will add the namespace for you anyway. Or, just make it a struct, and then you don't need to worry about it being null.

Having said all that, I think the new suggested names in general are fine.

I'd like @DamianEdwards / @davidfowl / @blowdart to share any thoughts they have on those before committing to anything.

@blowdart
Copy link
Member

I'm good with the naming changes.

cesarblum pushed a commit that referenced this issue Jun 23, 2017
…#1901).

- IHttpRequestBodyMinimumDataRateFeature -> IHttpMinRequestBodyDataRateFeature
- KestrelServerLimits.RequestBodyMinimumDataRate -> MinRequestBodyDataRate
- Also rename "rate" param and property of MinimumDataRate to "bytesPerSecond"
cesarblum pushed a commit that referenced this issue Jun 24, 2017
…#1901).

- IHttpRequestBodyMinimumDataRateFeature -> IHttpMinRequestBodyDataRateFeature
- KestrelServerLimits.RequestBodyMinimumDataRate -> MinRequestBodyDataRate
- Also rename "rate" param and property of MinimumDataRate to "bytesPerSecond"
cesarblum pushed a commit that referenced this issue Jun 29, 2017
…#1901).

- IHttpRequestBodyMinimumDataRateFeature -> IHttpMinRequestBodyDataRateFeature
- KestrelServerLimits.RequestBodyMinimumDataRate -> MinRequestBodyDataRate
- Also rename "rate" param and property of MinimumDataRate to "bytesPerSecond"
cesarblum pushed a commit that referenced this issue Jun 29, 2017
…#1901).

- IHttpRequestBodyMinimumDataRateFeature -> IHttpMinRequestBodyDataRateFeature
- KestrelServerLimits.RequestBodyMinimumDataRate -> MinRequestBodyDataRate
- Also rename "rate" param and property of MinimumDataRate to "bytesPerSecond"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants