Upgrading dependency to Thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-11-27 18:03:50 -08:00
parent 3e4590dcc0
commit 356978cb42
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1302 changed files with 101701 additions and 26784 deletions

View file

@ -24,8 +24,6 @@ BUILT_SOURCES = trusted-ca-certificate.pem server-certificate.pem
# Thrift compiler rules
THRIFT = $(top_builddir)/compiler/cpp/thrift
debug_proto_gen = $(addprefix gen-d/, DebugProtoTest_types.d)
$(debug_proto_gen): $(top_srcdir)/test/DebugProtoTest.thrift

View file

@ -409,8 +409,8 @@ void asyncAggregatorTest(const(ushort)[] ports, ExTestHandler[] handlers) {
)();
Thread.sleep(dur!"msecs"(20));
auto resultTuple = partialResult.finishGet();
enforce(resultTuple._0 == ports[0 .. 2]);
enforce(equal(map!"a.port"(cast(TestServiceException[])resultTuple._1),
enforce(resultTuple[0] == ports[0 .. 2]);
enforce(equal(map!"a.port"(cast(TestServiceException[])resultTuple[1]),
ports[3 .. $ - 1]));
}
}

View file

@ -13,7 +13,7 @@
*/
module serialization_benchmark;
import std.datetime : AutoStart, StopWatch;
import std.datetime.stopwatch : AutoStart, StopWatch;
import std.math : PI;
import std.stdio;
import thrift.protocol.binary;
@ -46,7 +46,7 @@ void main() {
}
sw.stop();
auto msecs = sw.peek().msecs;
auto msecs = sw.peek().total!"msecs";
writefln("Write: %s ms (%s kHz)", msecs, ITERATIONS / msecs);
}
@ -64,7 +64,7 @@ void main() {
}
sw.stop();
auto msecs = sw.peek().msecs;
auto msecs = sw.peek().total!"msecs";
writefln(" Read: %s ms (%s kHz)", msecs, ITERATIONS / msecs);
}
}

View file

@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
module thrift_test_server;
import core.stdc.errno : errno;
import core.stdc.signal : signal, sigfn_t, SIGINT, SIG_DFL, SIG_ERR;
import core.thread : dur, Thread;
import std.algorithm;
import std.exception : enforce;
@ -40,6 +43,7 @@ import thrift.transport.buffered;
import thrift.transport.framed;
import thrift.transport.http;
import thrift.transport.ssl;
import thrift.util.cancellation;
import thrift.util.hashset;
import test_utils;
@ -205,14 +209,44 @@ private:
bool trace_;
}
shared(bool) gShutdown = false;
nothrow @nogc extern(C) void handleSignal(int sig) {
gShutdown = true;
}
// Runs a thread that waits for shutdown to be
// signaled and then triggers cancellation,
// causing the server to stop. While we could
// use a signalfd for this purpose, we are instead
// opting for a busy waiting scheme for maximum
// portability since signalfd is a linux thing.
class ShutdownThread : Thread {
this(TCancellationOrigin cancellation) {
cancellation_ = cancellation;
super(&run);
}
private:
void run() {
while (!gShutdown) {
Thread.sleep(dur!("msecs")(25));
}
cancellation_.trigger();
}
TCancellationOrigin cancellation_;
}
void main(string[] args) {
ushort port = 9090;
ServerType serverType;
ProtocolType protocolType;
size_t numIOThreads = 1;
TransportType transportType;
bool ssl;
bool trace;
bool ssl = false;
bool trace = true;
size_t taskPoolSize = totalCPUs;
getopt(args, "port", &port, "protocol", &protocolType, "server-type",
@ -279,8 +313,26 @@ void main(string[] args) {
auto server = createServer(serverType, numIOThreads, taskPoolSize,
processor, serverSocket, transportFactory, protocolFactory);
// Set up SIGINT signal handling
sigfn_t oldHandler = signal(SIGINT, &handleSignal);
enforce(oldHandler != SIG_ERR,
"Could not replace the SIGINT signal handler: errno {0}".format(errno()));
// Set up a server cancellation trigger
auto cancel = new TCancellationOrigin();
// Set up a listener for the shutdown condition - this will
// wake up when the signal occurs and trigger cancellation.
auto shutdown = new ShutdownThread(cancel);
shutdown.start();
// Serve from this thread; the signal will stop the server
// and control will return here
writefln("Starting %s/%s %s ThriftTest server %son port %s...", protocolType,
transportType, serverType, ssl ? "(using SSL) ": "", port);
server.serve();
server.serve(cancel);
shutdown.join();
signal(SIGINT, SIG_DFL);
writeln("done.");
}