THRIFT-5021 Implement MAX_MESSAGE_SIZE and centralize limits into a TConfiguration class
Client: netstd
Patch: Jens Geyer
This closes #1943
diff --git a/test/netstd/Client/Performance/PerformanceTests.cs b/test/netstd/Client/Performance/PerformanceTests.cs
index 041d12e..05c64b2 100644
--- a/test/netstd/Client/Performance/PerformanceTests.cs
+++ b/test/netstd/Client/Performance/PerformanceTests.cs
@@ -20,6 +20,7 @@
using System.Text;
using ThriftTest;
using Thrift.Collections;
+using Thrift;
using Thrift.Protocol;
using System.Threading;
using Thrift.Transport.Client;
@@ -36,6 +37,7 @@
private TMemoryBufferTransport MemBuffer;
private TTransport Transport;
private LayeredChoice Layered;
+ private readonly TConfiguration Configuration = new TConfiguration();
internal static int Execute()
{
@@ -52,6 +54,11 @@
return 0;
}
+ public PerformanceTests()
+ {
+ Configuration.MaxFrameSize = Configuration.MaxMessageSize; // default frame size is too small for this test
+ }
+
private async Task ProtocolPeformanceTestAsync()
{
Console.WriteLine("Setting up for ProtocolPeformanceTestAsync ...");
@@ -76,9 +83,9 @@
{
// read happens after write here, so let's take over the written bytes
if (forWrite)
- MemBuffer = new TMemoryBufferTransport();
+ MemBuffer = new TMemoryBufferTransport(Configuration);
else
- MemBuffer = new TMemoryBufferTransport(MemBuffer.GetBuffer());
+ MemBuffer = new TMemoryBufferTransport(MemBuffer.GetBuffer(), Configuration);
// layered transports anyone?
switch (Layered)
diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index 13ae313..0c147dc 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -28,6 +28,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Thrift;
using Thrift.Collections;
using Thrift.Protocol;
using Thrift.Transport;
@@ -72,6 +73,7 @@
public LayeredChoice layered = LayeredChoice.None;
public ProtocolChoice protocol = ProtocolChoice.Binary;
public TransportChoice transport = TransportChoice.Socket;
+ private readonly TConfiguration Configuration = null; // or new TConfiguration() if needed
internal void Parse(List<string> args)
{
@@ -235,12 +237,12 @@
{
case TransportChoice.Http:
Debug.Assert(url != null);
- trans = new THttpTransport(new Uri(url), null);
+ trans = new THttpTransport(new Uri(url), Configuration);
break;
case TransportChoice.NamedPipe:
Debug.Assert(pipe != null);
- trans = new TNamedPipeTransport(pipe);
+ trans = new TNamedPipeTransport(pipe,Configuration);
break;
case TransportChoice.TlsSocket:
@@ -250,14 +252,15 @@
throw new InvalidOperationException("Certificate doesn't contain private key");
}
- trans = new TTlsSocketTransport(host, port, 0, cert,
+ trans = new TTlsSocketTransport(host, port, Configuration, 0,
+ cert,
(sender, certificate, chain, errors) => true,
null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
break;
case TransportChoice.Socket:
default:
- trans = new TSocketTransport(host, port);
+ trans = new TSocketTransport(host, port, Configuration);
break;
}