-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Akka.IO: redesign TcpConnection
#7637
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
Changes from all commits
d453f94
03b27d8
fc37584
0b5d391
4901869
2e5fd78
a75b0c8
b5f0d5d
1e8705a
37b8d0a
49dced2
187b267
5a7a24e
cd6c64c
41af0d6
08fe864
c02a9a1
477ce05
5940b72
2d44cc4
334a2e4
d74cbd7
7ce01a6
e205480
e3611f8
231c521
ea4294f
e06f81e
284bbb4
df52514
e96c539
f8df406
d8dd04a
eb16a65
ab65ef7
d8e580d
87a0175
79cf97e
db0eaf0
6589ae2
5ad22b4
6f1668a
edbca26
b7aa8dd
cd7814b
b601351
af4973e
3c40fa1
4c7be29
f7e7d98
b4c5fa3
5fa23bf
f15802a
0c00783
8413020
9e9cd2c
4237808
3ee94cb
547474a
fbae5d6
c4efa93
5974533
ad63320
30e5a28
24eb50b
e3331ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2269,6 +2269,7 @@ namespace Akka.Configuration | |
| public virtual System.Collections.Generic.IList<bool> GetBooleanList(string path) { } | ||
| public virtual System.Collections.Generic.IList<byte> GetByteList(string path) { } | ||
| public virtual System.Nullable<long> GetByteSize(string path) { } | ||
| [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("def")] | ||
| public virtual System.Nullable<long> GetByteSize(string path, System.Nullable<long> def = null) { } | ||
| public virtual Akka.Configuration.Config GetConfig(string path) { } | ||
| public virtual decimal GetDecimal(string path, [System.Runtime.CompilerServices.DecimalConstantAttribute(0, 0, 0u, 0u, 0u)] decimal @default) { } | ||
|
|
@@ -4001,6 +4002,8 @@ namespace Akka.IO | |
| public System.Net.EndPoint LocalAddress { get; } | ||
| public System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> Options { get; } | ||
| public bool PullMode { get; } | ||
| [System.Runtime.CompilerServices.NullableAttribute(2)] | ||
| public Akka.IO.TcpSettings TcpSettings { get; set; } | ||
| public override string ToString() { } | ||
| } | ||
| public sealed class Bound : Akka.IO.Tcp.Event | ||
|
|
@@ -4043,6 +4046,7 @@ namespace Akka.IO | |
| public sealed class CompoundWrite : Akka.IO.Tcp.WriteCommand, System.Collections.Generic.IEnumerable<Akka.IO.Tcp.SimpleWriteCommand>, System.Collections.IEnumerable | ||
| { | ||
| public CompoundWrite(Akka.IO.Tcp.SimpleWriteCommand head, Akka.IO.Tcp.WriteCommand tailCommand) { } | ||
| public override long Bytes { get; } | ||
| public Akka.IO.Tcp.SimpleWriteCommand Head { get; } | ||
| public Akka.IO.Tcp.WriteCommand TailCommand { get; } | ||
| public System.Collections.Generic.IEnumerator<Akka.IO.Tcp.SimpleWriteCommand> GetEnumerator() { } | ||
|
|
@@ -4065,6 +4069,8 @@ namespace Akka.IO | |
| public System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> Options { get; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These really need to be obsoleted and deleted |
||
| public bool PullMode { get; } | ||
| public System.Net.EndPoint RemoteAddress { get; } | ||
| [System.Runtime.CompilerServices.NullableAttribute(2)] | ||
| public Akka.IO.TcpSettings TcpSettings { get; set; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Customize |
||
| public System.Nullable<System.TimeSpan> Timeout { get; } | ||
| public override string ToString() { } | ||
| } | ||
|
|
@@ -4184,6 +4190,7 @@ namespace Akka.IO | |
| { | ||
| public static readonly Akka.IO.Tcp.Write Empty; | ||
| public override Akka.IO.Tcp.Event Ack { get; } | ||
| public override long Bytes { get; } | ||
| public Akka.IO.ByteString Data { get; } | ||
| public static Akka.IO.Tcp.Write Create(Akka.IO.ByteString data) { } | ||
| public static Akka.IO.Tcp.Write Create(Akka.IO.ByteString data, Akka.IO.Tcp.Event ack) { } | ||
|
|
@@ -4192,6 +4199,7 @@ namespace Akka.IO | |
| public abstract class WriteCommand : Akka.IO.Tcp.Command | ||
| { | ||
| protected WriteCommand() { } | ||
| public abstract long Bytes { get; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New field so we can instantly measure how long our output is - need this for buffer-overflow checking |
||
| public static Akka.IO.Tcp.WriteCommand Create(System.Collections.Generic.IEnumerable<Akka.IO.Tcp.WriteCommand> writes) { } | ||
| public static Akka.IO.Tcp.WriteCommand Create(params WriteCommand[] writes) { } | ||
| public Akka.IO.Tcp.CompoundWrite Prepend(Akka.IO.Tcp.SimpleWriteCommand other) { } | ||
|
|
@@ -4205,7 +4213,6 @@ namespace Akka.IO | |
| public sealed class TcpExt : Akka.IO.IOExtension | ||
| { | ||
| public TcpExt(Akka.Actor.ExtendedActorSystem system) { } | ||
| public Akka.IO.Buffers.IBufferPool BufferPool { get; } | ||
| public override Akka.Actor.IActorRef Manager { get; } | ||
| public Akka.IO.TcpSettings Settings { get; } | ||
| } | ||
|
|
@@ -4231,21 +4238,31 @@ namespace Akka.IO | |
| public static Akka.IO.Tcp.Command Unbind() { } | ||
| public static Akka.IO.Tcp.Command Write(Akka.IO.ByteString data, Akka.IO.Tcp.Event ack = null) { } | ||
| } | ||
| public class TcpSettings | ||
| public sealed class TcpSettings : System.IEquatable<Akka.IO.TcpSettings> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now a |
||
| { | ||
| [System.ObsoleteAttribute("Many of these options are no longer used. Use the TcpSettings.Create method inste" + | ||
| "ad.")] | ||
| public TcpSettings(string bufferPoolConfigPath, int initialSocketAsyncEventArgs, bool traceLogging, int batchAcceptLimit, System.Nullable<System.TimeSpan> registerTimeout, int receivedMessageSizeLimit, string managementDispatcher, string fileIoDispatcher, int transferToLimit, int finishConnectRetries, bool outgoingSocketForceIpv4, int writeCommandsQueueMaxSize) { } | ||
| public int BatchAcceptLimit { get; } | ||
| public int BatchAcceptLimit { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public string BufferPoolConfigPath { get; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public string FileIODispatcher { get; } | ||
| public int FinishConnectRetries { get; } | ||
| public int FinishConnectRetries { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public int InitialSocketAsyncEventArgs { get; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use this setting anymore - the |
||
| public string ManagementDispatcher { get; } | ||
| public bool OutgoingSocketForceIpv4 { get; } | ||
| public int ReceivedMessageSizeLimit { get; } | ||
| public System.Nullable<System.TimeSpan> RegisterTimeout { get; } | ||
| public bool TraceLogging { get; } | ||
| public int MaxFrameSizeBytes { get; set; } | ||
| public bool OutgoingSocketForceIpv4 { get; set; } | ||
| public int ReceiveBufferSize { get; set; } | ||
| [System.ObsoleteAttribute("This property is now MaxFrameSizeBytes")] | ||
| public long ReceivedMessageSizeLimit { get; } | ||
| public System.Nullable<System.TimeSpan> RegisterTimeout { get; set; } | ||
| public int SendBufferSize { get; set; } | ||
| public bool TraceLogging { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public int TransferToLimit { get; set; } | ||
| public int WriteCommandsQueueMaxSize { get; } | ||
| public int WriteCommandsQueueMaxSize { get; set; } | ||
| public static Akka.IO.TcpSettings Create(Akka.Actor.ActorSystem system) { } | ||
| public static Akka.IO.TcpSettings Create(Akka.Configuration.Config config) { } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3991,6 +3991,8 @@ namespace Akka.IO | |
| public System.Net.EndPoint LocalAddress { get; } | ||
| public System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> Options { get; } | ||
| public bool PullMode { get; } | ||
| [System.Runtime.CompilerServices.NullableAttribute(2)] | ||
| public Akka.IO.TcpSettings TcpSettings { get; set; } | ||
| public override string ToString() { } | ||
| } | ||
| public sealed class Bound : Akka.IO.Tcp.Event | ||
|
|
@@ -4033,6 +4035,7 @@ namespace Akka.IO | |
| public sealed class CompoundWrite : Akka.IO.Tcp.WriteCommand, System.Collections.Generic.IEnumerable<Akka.IO.Tcp.SimpleWriteCommand>, System.Collections.IEnumerable | ||
| { | ||
| public CompoundWrite(Akka.IO.Tcp.SimpleWriteCommand head, Akka.IO.Tcp.WriteCommand tailCommand) { } | ||
| public override long Bytes { get; } | ||
| public Akka.IO.Tcp.SimpleWriteCommand Head { get; } | ||
| public Akka.IO.Tcp.WriteCommand TailCommand { get; } | ||
| public System.Collections.Generic.IEnumerator<Akka.IO.Tcp.SimpleWriteCommand> GetEnumerator() { } | ||
|
|
@@ -4055,6 +4058,8 @@ namespace Akka.IO | |
| public System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> Options { get; } | ||
| public bool PullMode { get; } | ||
| public System.Net.EndPoint RemoteAddress { get; } | ||
| [System.Runtime.CompilerServices.NullableAttribute(2)] | ||
| public Akka.IO.TcpSettings TcpSettings { get; set; } | ||
| public System.Nullable<System.TimeSpan> Timeout { get; } | ||
| public override string ToString() { } | ||
| } | ||
|
|
@@ -4174,6 +4179,7 @@ namespace Akka.IO | |
| { | ||
| public static readonly Akka.IO.Tcp.Write Empty; | ||
| public override Akka.IO.Tcp.Event Ack { get; } | ||
| public override long Bytes { get; } | ||
| public Akka.IO.ByteString Data { get; } | ||
| public static Akka.IO.Tcp.Write Create(Akka.IO.ByteString data) { } | ||
| public static Akka.IO.Tcp.Write Create(Akka.IO.ByteString data, Akka.IO.Tcp.Event ack) { } | ||
|
|
@@ -4182,6 +4188,7 @@ namespace Akka.IO | |
| public abstract class WriteCommand : Akka.IO.Tcp.Command | ||
| { | ||
| protected WriteCommand() { } | ||
| public abstract long Bytes { get; } | ||
| public static Akka.IO.Tcp.WriteCommand Create(System.Collections.Generic.IEnumerable<Akka.IO.Tcp.WriteCommand> writes) { } | ||
| public static Akka.IO.Tcp.WriteCommand Create(params WriteCommand[] writes) { } | ||
| public Akka.IO.Tcp.CompoundWrite Prepend(Akka.IO.Tcp.SimpleWriteCommand other) { } | ||
|
|
@@ -4195,7 +4202,6 @@ namespace Akka.IO | |
| public sealed class TcpExt : Akka.IO.IOExtension | ||
| { | ||
| public TcpExt(Akka.Actor.ExtendedActorSystem system) { } | ||
| public Akka.IO.Buffers.IBufferPool BufferPool { get; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used |
||
| public override Akka.Actor.IActorRef Manager { get; } | ||
| public Akka.IO.TcpSettings Settings { get; } | ||
| } | ||
|
|
@@ -4221,21 +4227,31 @@ namespace Akka.IO | |
| public static Akka.IO.Tcp.Command Unbind() { } | ||
| public static Akka.IO.Tcp.Command Write(Akka.IO.ByteString data, Akka.IO.Tcp.Event ack = null) { } | ||
| } | ||
| public class TcpSettings | ||
| public sealed class TcpSettings : System.IEquatable<Akka.IO.TcpSettings> | ||
| { | ||
| [System.ObsoleteAttribute("Many of these options are no longer used. Use the TcpSettings.Create method inste" + | ||
| "ad.")] | ||
| public TcpSettings(string bufferPoolConfigPath, int initialSocketAsyncEventArgs, bool traceLogging, int batchAcceptLimit, System.Nullable<System.TimeSpan> registerTimeout, int receivedMessageSizeLimit, string managementDispatcher, string fileIoDispatcher, int transferToLimit, int finishConnectRetries, bool outgoingSocketForceIpv4, int writeCommandsQueueMaxSize) { } | ||
| public int BatchAcceptLimit { get; } | ||
| public int BatchAcceptLimit { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public string BufferPoolConfigPath { get; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public string FileIODispatcher { get; } | ||
| public int FinishConnectRetries { get; } | ||
| public int FinishConnectRetries { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public int InitialSocketAsyncEventArgs { get; } | ||
| public string ManagementDispatcher { get; } | ||
| public bool OutgoingSocketForceIpv4 { get; } | ||
| public int ReceivedMessageSizeLimit { get; } | ||
| public System.Nullable<System.TimeSpan> RegisterTimeout { get; } | ||
| public bool TraceLogging { get; } | ||
| public int MaxFrameSizeBytes { get; set; } | ||
| public bool OutgoingSocketForceIpv4 { get; set; } | ||
| public int ReceiveBufferSize { get; set; } | ||
| [System.ObsoleteAttribute("This property is now MaxFrameSizeBytes")] | ||
| public long ReceivedMessageSizeLimit { get; } | ||
| public System.Nullable<System.TimeSpan> RegisterTimeout { get; set; } | ||
| public int SendBufferSize { get; set; } | ||
| public bool TraceLogging { get; set; } | ||
| [System.ObsoleteAttribute("This property is unused")] | ||
| public int TransferToLimit { get; set; } | ||
| public int WriteCommandsQueueMaxSize { get; } | ||
| public int WriteCommandsQueueMaxSize { get; set; } | ||
| public static Akka.IO.TcpSettings Create(Akka.Actor.ActorSystem system) { } | ||
| public static Akka.IO.TcpSettings Create(Akka.Configuration.Config config) { } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| //----------------------------------------------------------------------- | ||
| //----------------------------------------------------------------------- | ||
| // <copyright file="TcpSpec.cs" company="Akka.NET Project"> | ||
| // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
| // Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
|
|
@@ -29,9 +29,11 @@ namespace Akka.Streams.Tests.IO | |
| { | ||
| public class TcpSpec : TcpHelper | ||
| { | ||
| public TcpSpec(ITestOutputHelper helper) : base(@" | ||
| akka.loglevel = DEBUG | ||
| akka.stream.materializer.subscription-timeout.timeout = 2s", helper) | ||
| public TcpSpec(ITestOutputHelper helper) : base(""" | ||
| akka.io.tcp.trace-logging = on | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turned trace logging on here to help me debug some issues with the design |
||
| akka.loglevel = DEBUG | ||
| akka.stream.materializer.subscription-timeout.timeout = 2s | ||
| """, helper) | ||
| { | ||
| } | ||
|
|
||
|
|
@@ -40,7 +42,7 @@ public async Task Outgoing_TCP_stream_must_work_in_the_happy_case() | |
| { | ||
| await this.AssertAllStagesStoppedAsync(async () => | ||
| { | ||
| var testData = ByteString.FromBytes(new byte[] {1, 2, 3, 4, 5}); | ||
| var testData = ByteString.FromBytes([1, 2, 3, 4, 5]); | ||
|
|
||
| var server = await new Server(this).InitializeAsync(); | ||
| var tcpReadProbe = new TcpReadProbe(this); | ||
|
|
@@ -65,7 +67,7 @@ await ValidateServerClientCommunicationAsync(testData, serverConnection, tcpRead | |
| public async Task Outgoing_TCP_stream_must_be_able_to_write_a_sequence_of_ByteStrings() | ||
| { | ||
| var server = await new Server(this).InitializeAsync(); | ||
| var testInput = Enumerable.Range(0, 256).Select(i => ByteString.FromBytes(new byte[] {Convert.ToByte(i)})); | ||
| var testInput = Enumerable.Range(0, 256).Select(i => ByteString.FromBytes([Convert.ToByte(i)])); | ||
| var expectedOutput = ByteString.FromBytes(Enumerable.Range(0, 256).Select(Convert.ToByte).ToArray()); | ||
|
|
||
| Source.From(testInput) | ||
|
|
@@ -86,7 +88,7 @@ public async Task Outgoing_TCP_stream_must_be_able_to_read_a_sequence_of_ByteStr | |
| var testOutput = new byte[255]; | ||
| for (byte i = 0; i < 255; i++) | ||
| { | ||
| testInput[i] = ByteString.FromBytes(new [] {i}); | ||
| testInput[i] = ByteString.FromBytes([i]); | ||
| testOutput[i] = i; | ||
| } | ||
|
|
||
|
|
@@ -103,6 +105,7 @@ public async Task Outgoing_TCP_stream_must_be_able_to_read_a_sequence_of_ByteStr | |
| serverConnection.Write(input); | ||
|
|
||
| serverConnection.ConfirmedClose(); | ||
| // Reduced timeout - otherwise we're just waiting longer for the failure | ||
| var result = await resultFuture.ShouldCompleteWithin(3.Seconds()); | ||
| result.ShouldBe(expectedOutput); | ||
| } | ||
|
|
@@ -132,7 +135,7 @@ public async Task Outgoing_TCP_stream_must_work_when_client_closes_write_then_re | |
| { | ||
| await this.AssertAllStagesStoppedAsync(async () => | ||
| { | ||
| var testData = ByteString.FromBytes(new byte[] { 1, 2, 3, 4, 5 }); | ||
| var testData = ByteString.FromBytes([1, 2, 3, 4, 5]); | ||
| var server = await new Server(this).InitializeAsync(); | ||
|
|
||
| var tcpWriteProbe = new TcpWriteProbe(this); | ||
|
|
@@ -466,7 +469,7 @@ public async Task Outgoing_TCP_stream_must_Echo_should_work_even_if_server_is_in | |
| .Run(Materializer); | ||
|
|
||
| var result = await Source.From(Enumerable.Repeat(0, 1000) | ||
| .Select(i => ByteString.FromBytes(new byte[] { Convert.ToByte(i) }))) | ||
| .Select(i => ByteString.FromBytes([Convert.ToByte(i)]))) | ||
| .Via(Sys.TcpStream().OutgoingConnection(serverAddress, halfClose: true)) | ||
| .RunAggregate(0, (i, s) => i + s.Count, Materializer).ShouldCompleteWithin(10.Seconds()); | ||
|
|
||
|
|
@@ -503,7 +506,7 @@ await WithinAsync(TimeSpan.FromSeconds(15), async () => | |
| await AwaitAssertAsync(async () => | ||
| { | ||
| // Getting rid of existing connection actors by using a blunt instrument | ||
| system2.ActorSelection(system2.Tcp().Path / "$a" / "*").Tell(Kill.Instance); | ||
| system2.ActorSelection(system2.Tcp().Path / "tcp-client-connection-*").Tell(Kill.Instance); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| await result.ShouldCompleteWithin(3.Seconds()); | ||
| }, interval:TimeSpan.FromSeconds(4)); | ||
|
|
@@ -525,6 +528,7 @@ await AwaitAssertAsync(async () => | |
| public async Task Outgoing_TCP_stream_must_not_thrown_on_unbind_after_system_has_been_shut_down() | ||
| { | ||
| var sys2 = ActorSystem.Create("shutdown-test-system", Sys.Settings.Config); | ||
| InitializeLogger(sys2); | ||
|
|
||
| try | ||
| { | ||
|
|
@@ -573,7 +577,7 @@ public async Task Tcp_listen_stream_must_be_able_to_implement_echo() | |
| var binding = await bindTask.ShouldCompleteWithin(3.Seconds()); | ||
|
|
||
| var testInput = Enumerable.Range(0, 255) | ||
| .Select(i => ByteString.FromBytes(new byte[] { Convert.ToByte(i) })) | ||
| .Select(i => ByteString.FromBytes([Convert.ToByte(i)])) | ||
| .ToList(); | ||
|
|
||
| var expectedOutput = testInput.Aggregate(ByteString.Empty, (agg, b) => agg.Concat(b)); | ||
|
|
@@ -603,7 +607,7 @@ public async Task Tcp_listen_stream_must_work_with_a_chain_of_echoes() | |
| var echoConnection = Sys.TcpStream().OutgoingConnection(serverAddress); | ||
|
|
||
| var testInput = Enumerable.Range(0, 255) | ||
| .Select(i => ByteString.FromBytes(new byte[] { Convert.ToByte(i) })) | ||
| .Select(i => ByteString.FromBytes([Convert.ToByte(i)])) | ||
| .ToList(); | ||
|
|
||
| var expectedOutput = testInput.Aggregate(ByteString.Empty, (agg, b) => agg.Concat(b)); | ||
|
|
||
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.
Customize
TcpSettingson per-Bindbasis. Set as a mutable property since I didn't want to manipulate the CTORThere 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 it possible to duplicate the constructor and replace the old
SocketOptionwithTcpSettingsinstead? We can then mark the old .ctor as obsolete