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

Commit 0a1be15

Browse files
committed
Rename IKestrelConfigurationBuilder to IKestrelConfigurationLoader
1 parent 3183ad7 commit 0a1be15

File tree

7 files changed

+45
-45
lines changed

7 files changed

+45
-45
lines changed

samples/SampleApp/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static Task Main(string[] args)
109109
.Configure()
110110
.Endpoint(IPAddress.Loopback, basePort + 5)
111111
.LocalhostEndpoint(basePort + 6)
112-
.Build();
112+
.Load();
113113

114114
options
115115
.Configure(context.Configuration.GetSection("Kestrel"))

src/Kestrel.Core/Internal/IKestrelConfigurationBuilder.cs renamed to src/Kestrel.Core/Internal/IKestrelConfigurationLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
66
/// <summary>
77
/// Used to provide delayed, replaceable configuration of KestrelServerOptions
88
/// </summary>
9-
public interface IKestrelConfigurationBuilder
9+
public interface IKestrelConfigurationLoader
1010
{
11-
void Build();
11+
void Load();
1212
}
1313
}

src/Kestrel.Core/KestrelServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public void Dispose()
224224

225225
private void ValidateOptions()
226226
{
227-
Options.ConfigurationBuilder?.Build();
227+
Options.ConfigurationLoader?.Load();
228228

229229
if (Options.Limits.MaxRequestBufferSize.HasValue &&
230230
Options.Limits.MaxRequestBufferSize < Options.Limits.MaxRequestLineSize)

src/Kestrel.Core/KestrelServerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class KestrelServerOptions
6161
/// Provides a configuration source where endpoints will be loaded from on server start.
6262
/// The default is null.
6363
/// </summary>
64-
public IKestrelConfigurationBuilder ConfigurationBuilder { get; set; }
64+
public IKestrelConfigurationLoader ConfigurationLoader { get; set; }
6565

6666
/// <summary>
6767
/// A default configuration action for all endpoints. Use for Listen, configuration, the default url, and URLs.

src/Kestrel/KestrelConfigurationBuilder.cs renamed to src/Kestrel/KestrelConfigurationLoader.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace Microsoft.AspNetCore.Server.Kestrel
1919
{
20-
public class KestrelConfigurationBuilder : IKestrelConfigurationBuilder
20+
public class KestrelConfigurationLoader : IKestrelConfigurationLoader
2121
{
22-
internal KestrelConfigurationBuilder(KestrelServerOptions options, IConfiguration configuration)
22+
internal KestrelConfigurationLoader(KestrelServerOptions options, IConfiguration configuration)
2323
{
2424
Options = options ?? throw new ArgumentNullException(nameof(options));
2525
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
@@ -29,13 +29,13 @@ internal KestrelConfigurationBuilder(KestrelServerOptions options, IConfiguratio
2929
public IConfiguration Configuration { get; }
3030
private IDictionary<string, Action<EndpointConfiguration>> EndpointConfigurations { get; }
3131
= new Dictionary<string, Action<EndpointConfiguration>>(0);
32-
// Actions that will be delayed until Build so that they aren't applied if the configuration builder is replaced.
32+
// Actions that will be delayed until Load so that they aren't applied if the configuration loader is replaced.
3333
private IList<Action> EndpointsToAdd { get; } = new List<Action>();
3434

3535
/// <summary>
3636
/// Specifies a configuration Action to run when an endpoint with the given name is loaded from configuration.
3737
/// </summary>
38-
public KestrelConfigurationBuilder Endpoint(string name, Action<EndpointConfiguration> configureOptions)
38+
public KestrelConfigurationLoader Endpoint(string name, Action<EndpointConfiguration> configureOptions)
3939
{
4040
if (string.IsNullOrEmpty(name))
4141
{
@@ -49,12 +49,12 @@ public KestrelConfigurationBuilder Endpoint(string name, Action<EndpointConfigur
4949
/// <summary>
5050
/// Bind to given IP address and port.
5151
/// </summary>
52-
public KestrelConfigurationBuilder Endpoint(IPAddress address, int port) => Endpoint(address, port, _ => { });
52+
public KestrelConfigurationLoader Endpoint(IPAddress address, int port) => Endpoint(address, port, _ => { });
5353

5454
/// <summary>
5555
/// Bind to given IP address and port.
5656
/// </summary>
57-
public KestrelConfigurationBuilder Endpoint(IPAddress address, int port, Action<ListenOptions> configure)
57+
public KestrelConfigurationLoader Endpoint(IPAddress address, int port, Action<ListenOptions> configure)
5858
{
5959
if (address == null)
6060
{
@@ -67,12 +67,12 @@ public KestrelConfigurationBuilder Endpoint(IPAddress address, int port, Action<
6767
/// <summary>
6868
/// Bind to given IP endpoint.
6969
/// </summary>
70-
public KestrelConfigurationBuilder Endpoint(IPEndPoint endPoint) => Endpoint(endPoint, _ => { });
70+
public KestrelConfigurationLoader Endpoint(IPEndPoint endPoint) => Endpoint(endPoint, _ => { });
7171

7272
/// <summary>
7373
/// Bind to given IP address and port.
7474
/// </summary>
75-
public KestrelConfigurationBuilder Endpoint(IPEndPoint endPoint, Action<ListenOptions> configure)
75+
public KestrelConfigurationLoader Endpoint(IPEndPoint endPoint, Action<ListenOptions> configure)
7676
{
7777
if (endPoint == null)
7878
{
@@ -95,13 +95,13 @@ public KestrelConfigurationBuilder Endpoint(IPEndPoint endPoint, Action<ListenOp
9595
/// Listens on ::1 and 127.0.0.1 with the given port. Requesting a dynamic port by specifying 0 is not supported
9696
/// for this type of endpoint.
9797
/// </summary>
98-
public KestrelConfigurationBuilder LocalhostEndpoint(int port) => LocalhostEndpoint(port, options => { });
98+
public KestrelConfigurationLoader LocalhostEndpoint(int port) => LocalhostEndpoint(port, options => { });
9999

100100
/// <summary>
101101
/// Listens on ::1 and 127.0.0.1 with the given port. Requesting a dynamic port by specifying 0 is not supported
102102
/// for this type of endpoint.
103103
/// </summary>
104-
public KestrelConfigurationBuilder LocalhostEndpoint(int port, Action<ListenOptions> configure)
104+
public KestrelConfigurationLoader LocalhostEndpoint(int port, Action<ListenOptions> configure)
105105
{
106106
if (configure == null)
107107
{
@@ -119,12 +119,12 @@ public KestrelConfigurationBuilder LocalhostEndpoint(int port, Action<ListenOpti
119119
/// <summary>
120120
/// Listens on all IPs using IPv6 [::], or IPv4 0.0.0.0 if IPv6 is not supported.
121121
/// </summary>
122-
public KestrelConfigurationBuilder AnyIPEndpoint(int port) => AnyIPEndpoint(port, options => { });
122+
public KestrelConfigurationLoader AnyIPEndpoint(int port) => AnyIPEndpoint(port, options => { });
123123

124124
/// <summary>
125125
/// Listens on all IPs using IPv6 [::], or IPv4 0.0.0.0 if IPv6 is not supported.
126126
/// </summary>
127-
public KestrelConfigurationBuilder AnyIPEndpoint(int port, Action<ListenOptions> configure)
127+
public KestrelConfigurationLoader AnyIPEndpoint(int port, Action<ListenOptions> configure)
128128
{
129129
if (configure == null)
130130
{
@@ -142,12 +142,12 @@ public KestrelConfigurationBuilder AnyIPEndpoint(int port, Action<ListenOptions>
142142
/// <summary>
143143
/// Bind to given Unix domain socket path.
144144
/// </summary>
145-
public KestrelConfigurationBuilder UnixSocketEndpoint(string socketPath) => UnixSocketEndpoint(socketPath, _ => { });
145+
public KestrelConfigurationLoader UnixSocketEndpoint(string socketPath) => UnixSocketEndpoint(socketPath, _ => { });
146146

147147
/// <summary>
148148
/// Bind to given Unix domain socket path.
149149
/// </summary>
150-
public KestrelConfigurationBuilder UnixSocketEndpoint(string socketPath, Action<ListenOptions> configure)
150+
public KestrelConfigurationLoader UnixSocketEndpoint(string socketPath, Action<ListenOptions> configure)
151151
{
152152
if (socketPath == null)
153153
{
@@ -173,12 +173,12 @@ public KestrelConfigurationBuilder UnixSocketEndpoint(string socketPath, Action<
173173
/// <summary>
174174
/// Open a socket file descriptor.
175175
/// </summary>
176-
public KestrelConfigurationBuilder HandleEndpoint(ulong handle) => HandleEndpoint(handle, _ => { });
176+
public KestrelConfigurationLoader HandleEndpoint(ulong handle) => HandleEndpoint(handle, _ => { });
177177

178178
/// <summary>
179179
/// Open a socket file descriptor.
180180
/// </summary>
181-
public KestrelConfigurationBuilder HandleEndpoint(ulong handle, Action<ListenOptions> configure)
181+
public KestrelConfigurationLoader HandleEndpoint(ulong handle, Action<ListenOptions> configure)
182182
{
183183
if (configure == null)
184184
{
@@ -193,14 +193,14 @@ public KestrelConfigurationBuilder HandleEndpoint(ulong handle, Action<ListenOpt
193193
return this;
194194
}
195195

196-
public void Build()
196+
public void Load()
197197
{
198-
if (Options.ConfigurationBuilder == null)
198+
if (Options.ConfigurationLoader == null)
199199
{
200-
// The builder has already been built.
200+
// The loader has already been run.
201201
return;
202202
}
203-
Options.ConfigurationBuilder = null;
203+
Options.ConfigurationLoader = null;
204204

205205
var configReader = new ConfigurationReader(Configuration);
206206

src/Kestrel/KestrelServerOptionsConfigurationExtensions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
88
public static class KestrelServerOptionsConfigurationExtensions
99
{
1010
/// <summary>
11-
/// Creates a configuration builder for setting up Kestrel.
11+
/// Creates a configuration loader for setting up Kestrel.
1212
/// </summary>
13-
public static KestrelConfigurationBuilder Configure(this KestrelServerOptions options)
13+
public static KestrelConfigurationLoader Configure(this KestrelServerOptions options)
1414
{
15-
var builder = new KestrelConfigurationBuilder(options, new ConfigurationBuilder().Build());
16-
options.ConfigurationBuilder = builder;
17-
return builder;
15+
var loader = new KestrelConfigurationLoader(options, new ConfigurationBuilder().Build());
16+
options.ConfigurationLoader = loader;
17+
return loader;
1818
}
1919

2020
/// <summary>
21-
/// Creates a configuration builder for setting up Kestrel that takes an IConfiguration as input.
21+
/// Creates a configuration loader for setting up Kestrel that takes an IConfiguration as input.
2222
/// </summary>
23-
public static KestrelConfigurationBuilder Configure(this KestrelServerOptions options, IConfiguration config)
23+
public static KestrelConfigurationLoader Configure(this KestrelServerOptions options, IConfiguration config)
2424
{
25-
var builder = new KestrelConfigurationBuilder(options, config);
26-
options.ConfigurationBuilder = builder;
27-
return builder;
25+
var loader = new KestrelConfigurationLoader(options, config);
26+
options.ConfigurationLoader = loader;
27+
return loader;
2828
}
2929
}
3030
}

test/Kestrel.Tests/KestrelConfigurationBuilderTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void ConfigureNamedEndpoint_OnlyRunForMatchingConfig()
4141
serverOptions.Configure(config)
4242
.Endpoint("Found", endpointOptions => found = true)
4343
.Endpoint("NotFound", endpointOptions => throw new NotImplementedException())
44-
.Build();
44+
.Load();
4545

4646
Assert.Single(serverOptions.ListenOptions);
4747
Assert.Equal(5001, serverOptions.ListenOptions[0].IPEndPoint.Port);
@@ -59,7 +59,7 @@ public void ConfigureEndpoint_OnlyRunWhenBuildIsCalled()
5959

6060
Assert.Empty(serverOptions.ListenOptions);
6161

62-
serverOptions.ConfigurationBuilder.Build();
62+
serverOptions.ConfigurationLoader.Load();
6363

6464
Assert.Single(serverOptions.ListenOptions);
6565
Assert.Equal(5001, serverOptions.ListenOptions[0].IPEndPoint.Port);
@@ -75,19 +75,19 @@ public void CallBuildTwice_OnlyRunsOnce()
7575
.LocalhostEndpoint(5001);
7676

7777
Assert.Empty(serverOptions.ListenOptions);
78-
Assert.Equal(builder, serverOptions.ConfigurationBuilder);
78+
Assert.Equal(builder, serverOptions.ConfigurationLoader);
7979

80-
builder.Build();
80+
builder.Load();
8181

8282
Assert.Single(serverOptions.ListenOptions);
8383
Assert.Equal(5001, serverOptions.ListenOptions[0].IPEndPoint.Port);
84-
Assert.Null(serverOptions.ConfigurationBuilder);
84+
Assert.Null(serverOptions.ConfigurationLoader);
8585

86-
builder.Build();
86+
builder.Load();
8787

8888
Assert.Single(serverOptions.ListenOptions);
8989
Assert.Equal(5001, serverOptions.ListenOptions[0].IPEndPoint.Port);
90-
Assert.Null(serverOptions.ConfigurationBuilder);
90+
Assert.Null(serverOptions.ConfigurationLoader);
9191
}
9292

9393
[Fact]
@@ -113,7 +113,7 @@ public void Configure_IsReplacable()
113113
serverOptions.Configure(config2)
114114
.LocalhostEndpoint(5003, endpointOptions => run2 = true);
115115

116-
serverOptions.ConfigurationBuilder.Build();
116+
serverOptions.ConfigurationLoader.Load();
117117

118118
Assert.Equal(2, serverOptions.ListenOptions.Count);
119119
Assert.Equal(5002, serverOptions.ListenOptions[0].IPEndPoint.Port);
@@ -159,7 +159,7 @@ public void ConfigureDefaultsAppliesToNewConfigureEndpoints()
159159
ran2 = true;
160160
Assert.False(opt.NoDelay);
161161
})
162-
.Build();
162+
.Load();
163163

164164
Assert.True(ran1);
165165
Assert.True(ran2);
@@ -203,7 +203,7 @@ public void ConfigureEndpointDefaultCanEnableHttps()
203203
ran2 = true;
204204
Assert.False(opt.NoDelay);
205205
})
206-
.Build();
206+
.Load();
207207

208208
Assert.True(ran1);
209209
Assert.True(ran2);

0 commit comments

Comments
 (0)