Skip to content

Commit 4fbcee7

Browse files
committed
fix(h3): wire MaxConnectionsPerServer and MaxConcurrentStreams to QUIC transport
1 parent 64129d0 commit 4fbcee7

7 files changed

Lines changed: 15 additions & 42 deletions

File tree

src/TurboHTTP/Internal/OptionsFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ internal static TransportOptions Build(RequestEndpoint endpoint, TurboClientOpti
3838
SocketReceiveBufferSize = clientOptions.SocketReceiveBufferSize,
3939
AllowConnectionMigration = clientOptions.Http3.AllowConnectionMigration,
4040
IdleTimeout = clientOptions.Http3.IdleTimeout,
41+
MaxConnectionsPerHost = clientOptions.Http3.MaxConnectionsPerServer,
42+
MaxBidirectionalStreams = clientOptions.Http3.MaxConcurrentStreams,
4143
ApplicationProtocols = alpn,
4244
AutoReconnect = true,
4345
ConnectionLifetime = clientOptions.PooledConnectionLifetime

src/TurboHTTP/Streams/Http10Engine.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@
66

77
namespace TurboHTTP.Streams;
88

9-
internal class Http10Engine : IHttpProtocolEngine
9+
internal class Http10Engine(TurboClientOptions options) : IHttpProtocolEngine
1010
{
11-
private readonly TurboClientOptions _options;
12-
13-
public Http10Engine(TurboClientOptions options)
14-
{
15-
_options = options;
16-
}
17-
1811
public BidiFlow<HttpRequestMessage, ITransportOutbound, ITransportInbound, HttpResponseMessage, NotUsed> CreateFlow()
1912
{
2013
return BidiFlow.FromGraph(GraphDsl.Create(b =>
2114
{
22-
var connection = b.Add(new Http10ConnectionStage(_options));
15+
var connection = b.Add(new Http10ConnectionStage(options));
2316

2417
return new BidiShape<
2518
HttpRequestMessage,

src/TurboHTTP/Streams/Http11Engine.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@
66

77
namespace TurboHTTP.Streams;
88

9-
internal class Http11Engine : IHttpProtocolEngine
9+
internal class Http11Engine(TurboClientOptions options) : IHttpProtocolEngine
1010
{
11-
private readonly TurboClientOptions _options;
12-
13-
14-
public Http11Engine(TurboClientOptions options)
15-
{
16-
_options = options;
17-
}
18-
1911
public BidiFlow<HttpRequestMessage, ITransportOutbound, ITransportInbound, HttpResponseMessage, NotUsed> CreateFlow()
2012
{
2113
return BidiFlow.FromGraph(GraphDsl.Create(b =>
2214
{
23-
var connection = b.Add(new Http11ConnectionStage(_options));
15+
var connection = b.Add(new Http11ConnectionStage(options));
2416

2517
return new BidiShape<
2618
HttpRequestMessage,

src/TurboHTTP/Streams/Http20Engine.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@
66

77
namespace TurboHTTP.Streams;
88

9-
internal class Http20Engine : IHttpProtocolEngine
9+
internal class Http20Engine(TurboClientOptions options) : IHttpProtocolEngine
1010
{
11-
private readonly TurboClientOptions _options;
12-
13-
public Http20Engine(TurboClientOptions options)
14-
{
15-
_options = options;
16-
}
17-
1811
public BidiFlow<HttpRequestMessage, ITransportOutbound, ITransportInbound, HttpResponseMessage, NotUsed> CreateFlow()
1912
{
2013
return BidiFlow.FromGraph(GraphDsl.Create(b =>
2114
{
22-
var connection = b.Add(new Http20ConnectionStage(_options));
15+
var connection = b.Add(new Http20ConnectionStage(options));
2316

2417
return new BidiShape<
2518
HttpRequestMessage,

src/TurboHTTP/Streams/Http30Engine.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@
66

77
namespace TurboHTTP.Streams;
88

9-
internal sealed class Http30Engine : IHttpProtocolEngine
9+
internal sealed class Http30Engine(TurboClientOptions options) : IHttpProtocolEngine
1010
{
11-
private readonly TurboClientOptions _options;
12-
13-
public Http30Engine(TurboClientOptions options)
14-
{
15-
_options = options;
16-
}
17-
1811
public BidiFlow<HttpRequestMessage, ITransportOutbound, ITransportInbound, HttpResponseMessage, NotUsed> CreateFlow()
1912
{
2013
return BidiFlow.FromGraph(GraphDsl.Create(b =>
2114
{
22-
var connection = b.Add(new Http30ConnectionStage(_options));
15+
var connection = b.Add(new Http30ConnectionStage(options));
2316

2417
return new BidiShape<
2518
HttpRequestMessage,

src/TurboHTTP/Streams/ProtocolCoreBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal static Flow<HttpRequestMessage, HttpResponseMessage, NotUsed> Build(
4545
return core.WithAttributes(highThroughputBuffer);
4646

4747
int MaxConcurrencyPerSlot(RequestEndpoint endpoint)
48-
=> GetMaxConcurrencyPerSlot(endpoint, h2Streams, clientOptions.Http1.MaxPipelineDepth, h3Streams);
48+
=> GetMaxConcurrencyPerSlot(endpoint, clientOptions.Http1.MaxPipelineDepth, h2Streams, h3Streams);
4949

5050
int MaxSubstreamsPerKey(RequestEndpoint endpoint)
5151
=> GetMaxSubstreamsPerKey(endpoint, maxConnsH1, maxConnsH2, maxConnsH3);
@@ -72,7 +72,7 @@ Flow<HttpRequestMessage, HttpResponseMessage, NotUsed> CreateFlowForEndpoint(Req
7272
}
7373
}
7474

75-
internal static int GetMaxConcurrencyPerSlot(RequestEndpoint endpoint, int h2Streams, int h1Streams, int h3Streams)
75+
internal static int GetMaxConcurrencyPerSlot(RequestEndpoint endpoint, int h1Streams, int h2Streams, int h3Streams)
7676
{
7777
return endpoint.Version switch
7878
{

src/TurboHTTP/TurboClientOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public sealed class TurboClientOptions
3030
public Uri? BaseAddress { get; set; }
3131

3232
/// <summary>HTTP/1.x-specific configuration.</summary>
33-
public Http1Options Http1 { get; set; } = new();
33+
public Http1Options Http1 { get; init; } = new();
3434

3535
/// <summary>HTTP/2-specific configuration.</summary>
36-
public Http2Options Http2 { get; set; } = new();
36+
public Http2Options Http2 { get; init; } = new();
3737

3838
/// <summary>HTTP/3-specific configuration.</summary>
39-
public Http3Options Http3 { get; set; } = new();
39+
public Http3Options Http3 { get; init; } = new();
4040

4141
/// <summary>
4242
/// Timeout for establishing a new TCP connection.

0 commit comments

Comments
 (0)