gorealis v2 refactor (#5)

* Changing default timeout for start maintenance.

* Upgrading dependencies to gorealis v2 and thrift  0.12.0

* Refactored to update to gorealis v2.
This commit is contained in:
Renan DelValle 2018-12-27 11:31:51 -08:00 committed by GitHub
parent ad4dd9606e
commit 6ab5c9334d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1335 changed files with 137431 additions and 61530 deletions

View file

@ -45,6 +45,8 @@ test_client_LDADD = \
test_server_SOURCES = \
src/thrift_test_handler.c \
src/thrift_test_handler.h \
src/thrift_second_service_handler.c \
src/thrift_second_service_handler.h \
src/test_server.c
test_server_LDADD = \
@ -54,8 +56,6 @@ test_server_LDADD = \
#
# Common thrift code generation rules
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-c_glib/t_test_second_service.c gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.c gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.c gen-c_glib/t_test_thrift_test_types.h: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen c_glib -r $<

View file

@ -28,11 +28,14 @@
#include <thrift/c_glib/thrift.h>
#include <thrift/c_glib/protocol/thrift_binary_protocol.h>
#include <thrift/c_glib/protocol/thrift_compact_protocol.h>
#include <thrift/c_glib/protocol/thrift_multiplexed_protocol.h>
#include <thrift/c_glib/transport/thrift_buffered_transport.h>
#include <thrift/c_glib/transport/thrift_framed_transport.h>
#include <thrift/c_glib/transport/thrift_ssl_socket.h>
#include <thrift/c_glib/transport/thrift_socket.h>
#include <thrift/c_glib/transport/thrift_transport.h>
#include "../gen-c_glib/t_test_second_service.h"
#include "../gen-c_glib/t_test_thrift_test.h"
/* Handle SIGPIPE signals (indicating the server has closed the
@ -72,42 +75,82 @@ gint32_compare (gconstpointer a, gconstpointer b)
return result;
}
/**
* It gets a multiplexed protocol which uses a concrete protocol underneath
* @param protocol_name the fully qualified protocol path (e.g. "binary:multi")
* @param transport the underlying transport
* @param service_name the single supported service name
* @todo need to allow multiple services to fully test multiplexed
* @return a multiplexed protocol wrapping the correct underlying protocol
*/
ThriftProtocol *
get_multiplexed_protocol(gchar *protocol_name, ThriftTransport *transport, gchar *service_name)
{
ThriftProtocol * multiplexed_protocol = NULL;
if ( strncmp(protocol_name, "binary:", 7) == 0) {
multiplexed_protocol = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
"transport", transport,
NULL);
} else if ( strncmp(protocol_name, "compact:", 8) == 0) {
multiplexed_protocol = g_object_new (THRIFT_TYPE_COMPACT_PROTOCOL,
"transport", transport,
NULL);
} else {
fprintf(stderr, "Unknown multiplex protocol name: %s\n", protocol_name);
return NULL;
}
return g_object_new (THRIFT_TYPE_MULTIPLEXED_PROTOCOL,
"transport", transport,
"protocol", multiplexed_protocol,
"service-name", service_name,
NULL);
}
int
main (int argc, char **argv)
{
static gchar *host = NULL;
static gint port = 9090;
static gchar *transport_option = NULL;
static gchar *protocol_option = NULL;
static gint num_tests = 1;
static gchar * host = NULL;
static gint port = 9090;
static gboolean ssl = FALSE;
static gchar * transport_option = NULL;
static gchar * protocol_option = NULL;
static gint num_tests = 1;
static
GOptionEntry option_entries[] ={
{ "host", 0, 0, G_OPTION_ARG_STRING, &host,
{ "host", 'h', 0, G_OPTION_ARG_STRING, &host,
"Host to connect (=localhost)", NULL },
{ "port", 0, 0, G_OPTION_ARG_INT, &port,
{ "port", 'p', 0, G_OPTION_ARG_INT, &port,
"Port number to connect (=9090)", NULL },
{ "transport", 0, 0, G_OPTION_ARG_STRING, &transport_option,
{ "ssl", 's', 0, G_OPTION_ARG_NONE, &ssl,
"Enable SSL", NULL },
{ "transport", 't', 0, G_OPTION_ARG_STRING, &transport_option,
"Transport: buffered, framed (=buffered)", NULL },
{ "protocol", 0, 0, G_OPTION_ARG_STRING, &protocol_option,
"Protocol: binary, compact (=binary)", NULL },
{ "testloops", 'n', 0, G_OPTION_ARG_INT, &num_tests,
{ "protocol", 'r', 0, G_OPTION_ARG_STRING, &protocol_option,
"Protocol: binary, compact, multi, multic (=binary)", NULL },
{ "testloops", 'n', 0, G_OPTION_ARG_INT, &num_tests,
"Number of tests (=1)", NULL },
{ NULL }
};
struct sigaction sigpipe_action;
GType socket_type = THRIFT_TYPE_SOCKET;
gchar *socket_name = "ip";
GType transport_type = THRIFT_TYPE_BUFFERED_TRANSPORT;
gchar *transport_name = "buffered";
GType protocol_type = THRIFT_TYPE_BINARY_PROTOCOL;
gchar *protocol_name = "binary";
ThriftSocket *socket;
ThriftTransport *transport;
ThriftProtocol *protocol;
ThriftSocket *socket = NULL;
ThriftTransport *transport = NULL;
ThriftProtocol *protocol = NULL;
ThriftProtocol *protocol2 = NULL; // for multiplexed tests
TTestThriftTestIf *test_client;
TTestThriftTestIf *test_client = NULL;
TTestSecondServiceIf *second_service = NULL; // for multiplexed tests
struct timeval time_start, time_stop, time_elapsed;
guint64 time_elapsed_usec, time_total_usec = 0;
@ -147,7 +190,18 @@ main (int argc, char **argv)
protocol_type = THRIFT_TYPE_COMPACT_PROTOCOL;
protocol_name = "compact";
}
else if (strncmp (protocol_option, "binary", 7) != 0) {
else if (strncmp (protocol_option, "multi", 6) == 0) {
protocol_type = THRIFT_TYPE_MULTIPLEXED_PROTOCOL;
protocol_name = "binary:multi";
}
else if (strncmp (protocol_option, "multic", 7) == 0) {
protocol_type = THRIFT_TYPE_MULTIPLEXED_PROTOCOL;
protocol_name = "compact:multic";
}
else if (strncmp (protocol_option, "binary", 7) == 0) {
printf("We are going with default protocol\n");
}
else {
fprintf (stderr, "Unknown protocol type %s\n", protocol_option);
options_valid = FALSE;
}
@ -164,12 +218,19 @@ main (int argc, char **argv)
}
}
if (ssl) {
socket_type = THRIFT_TYPE_SSL_SOCKET;
socket_name = "ip-ssl";
printf("Type name %s\n", g_type_name (socket_type));
}
if (!options_valid)
return 254;
printf ("Connecting (%s/%s) to: %s:%d\n",
printf ("Connecting (%s/%s) to: %s/%s:%d\n",
transport_name,
protocol_name,
socket_name,
host,
port);
@ -181,17 +242,50 @@ main (int argc, char **argv)
sigpipe_action.sa_flags = SA_RESETHAND;
sigaction (SIGPIPE, &sigpipe_action, NULL);
if (ssl) {
thrift_ssl_socket_initialize_openssl();
}
/* Establish all our connection objects */
socket = g_object_new (THRIFT_TYPE_SOCKET,
socket = g_object_new (socket_type,
"hostname", host,
"port", port,
NULL);
if (ssl && !thrift_ssl_load_cert_from_file(THRIFT_SSL_SOCKET(socket), "../keys/CA.pem")) {
fprintf(stderr, "Unable to load validation certificate ../keys/CA.pem - did you run in the test/c_glib directory?\n");
g_clear_object (&socket);
return 253;
}
transport = g_object_new (transport_type,
"transport", socket,
NULL);
protocol = g_object_new (protocol_type,
"transport", transport,
NULL);
if(protocol_type==THRIFT_TYPE_MULTIPLEXED_PROTOCOL) {
// TODO: A multiplexed test should also test "Second" (see Java TestServer)
// The context comes from the name of the thrift file. If multiple thrift
// schemas are used we have to redo the way this is done.
protocol = get_multiplexed_protocol(protocol_name, transport, "ThriftTest");
if (NULL == protocol) {
g_clear_object (&transport);
g_clear_object (&socket);
return 252;
}
// Make a second protocol and client running on the same multiplexed transport
protocol2 = get_multiplexed_protocol(protocol_name, transport, "SecondService");
second_service = g_object_new (T_TEST_TYPE_SECOND_SERVICE_CLIENT,
"input_protocol", protocol2,
"output_protocol", protocol2,
NULL);
}else{
protocol = g_object_new (protocol_type,
"transport", transport,
NULL);
}
test_client = g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT,
"input_protocol", protocol,
"output_protocol", protocol,
@ -277,10 +371,11 @@ main (int argc, char **argv)
printf (" = void\n");
}
else {
printf ("%s\n", error->message);
g_error_free (error);
error = NULL;
if(error!=NULL){
printf ("%s\n", error->message);
g_error_free (error);
error = NULL;
}
fail_count++;
}
@ -307,6 +402,31 @@ main (int argc, char **argv)
fail_count++;
}
/**
* Multiplexed Test - do this right in the middle of the normal Test Client run
*/
if (second_service) {
printf ("testSecondServiceMultiplexSecondTestString(\"2nd\")");
if (t_test_second_service_if_secondtest_string (second_service,
&string,
"2nd",
&error)) {
printf (" = \"%s\"\n", string);
if (strcmp (string, "testString(\"2nd\")") != 0) {
++fail_count;
}
g_free (string);
string = NULL;
} else {
printf ("%s\n", error->message);
g_error_free (error);
error = NULL;
++fail_count;
}
}
/**
* BOOL TEST
*/
@ -439,8 +559,105 @@ main (int argc, char **argv)
fail_count++;
}
// TODO: add testBinary()
/**
* BINARY TEST
*/
printf ("testBinary(empty)");
GByteArray *emptyArray = g_byte_array_new();
GByteArray *result = NULL;
if (t_test_thrift_test_if_test_binary (test_client,
&result,
emptyArray,
&error)) {
GBytes *response = g_byte_array_free_to_bytes(result); // frees result
result = NULL;
gsize siz = g_bytes_get_size(response);
if (siz == 0) {
printf(" = empty\n");
} else {
printf(" = not empty (%ld bytes)\n", (long)siz);
++fail_count;
}
g_bytes_unref(response);
} else {
printf ("%s\n", error->message);
g_error_free (error);
error = NULL;
fail_count++;
}
g_byte_array_unref(emptyArray);
emptyArray = NULL;
// TODO: add testBinary() with data
printf ("testBinary([-128..127]) = {");
const signed char bin_data[256]
= {-128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114,
-113, -112, -111, -110, -109, -108, -107, -106, -105, -104, -103, -102, -101, -100, -99,
-98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84,
-83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69,
-68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54,
-53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39,
-38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24,
-23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9,
-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127};
GByteArray *fullArray = g_byte_array_new();
g_byte_array_append(fullArray, (guint8 *)(&bin_data[0]), 256);
if (t_test_thrift_test_if_test_binary (test_client,
&result,
fullArray,
&error)) {
GBytes *response = g_byte_array_free_to_bytes(result); // frees result
result = NULL;
gsize siz = g_bytes_get_size(response);
gconstpointer ptr = g_bytes_get_data(response, &siz);
if (siz == 256) {
gboolean first = 1;
gboolean failed = 0;
int i;
for (i = 0; i < 256; ++i) {
if (!first)
printf(",");
else
first = 0;
int val = ((signed char *)ptr)[i];
printf("%d", val);
if (!failed && val != i - 128) {
failed = 1;
}
}
printf("} ");
if (failed) {
printf("FAIL (bad content) size %ld OK\n", (long)siz);
++fail_count;
} else {
printf("OK size %ld OK\n", (long)siz);
}
} else {
printf(" = bad size %ld\n", (long)siz);
++fail_count;
}
g_bytes_unref(response);
} else {
printf ("%s\n", error->message);
g_error_free (error);
error = NULL;
fail_count++;
}
g_byte_array_unref(fullArray);
fullArray = NULL;
/**
* STRUCT TEST
*/
@ -474,6 +691,11 @@ main (int argc, char **argv)
i32_thing != -3 ||
i64_thing != (gint64)-5)
fail_count++;
if (string) {
g_free (string);
string = NULL;
}
}
else {
printf ("%s\n", error->message);
@ -482,7 +704,8 @@ main (int argc, char **argv)
fail_count++;
}
g_object_unref (xtruct_in);
// g_clear_object(&xtruct_out); used below
g_clear_object(&xtruct_in);
/**
* NESTED STRUCT TEST
@ -525,6 +748,11 @@ main (int argc, char **argv)
inner_i64_thing != (gint64)-5 ||
i32_thing != 5)
fail_count++;
if (string) {
g_free(string);
string = NULL;
}
}
else {
printf ("%s\n", error->message);
@ -534,10 +762,10 @@ main (int argc, char **argv)
fail_count++;
}
g_object_unref (xtruct_in);
g_object_unref (xtruct2_in);
g_object_unref (xtruct2_out);
g_object_unref (xtruct_out);
g_clear_object(&xtruct_in);
g_clear_object(&xtruct2_in);
g_clear_object(&xtruct2_out);
g_clear_object(&xtruct_out);
/**
* MAP TEST
@ -1280,7 +1508,7 @@ main (int argc, char **argv)
}
g_hash_table_unref (map_in);
g_object_unref (insanity_out);
g_clear_object (&insanity_out);
/* test exception */
printf ("testClient.testException(\"Xception\") =>");
@ -1296,8 +1524,7 @@ main (int argc, char **argv)
printf (" {%u, \"%s\"}\n", int32, string);
g_free (string);
g_object_unref (xception);
xception = NULL;
g_clear_object (&xception);
g_error_free (error);
error = NULL;
@ -1333,10 +1560,7 @@ main (int argc, char **argv)
printf (" void\nFAILURE\n");
fail_count++;
if (xception != NULL) {
g_object_unref (xception);
xception = NULL;
}
g_clear_object (&xception);
if (error != NULL) {
g_error_free (error);
@ -1354,10 +1578,7 @@ main (int argc, char **argv)
printf (" void\nFAILURE\n");
fail_count++;
if (xception != NULL) {
g_object_unref (xception);
xception = NULL;
}
g_clear_object (&xception);
g_error_free (error);
error = NULL;
@ -1394,15 +1615,8 @@ main (int argc, char **argv)
printf (" result\nFAILURE\n");
fail_count++;
if (xception != NULL) {
g_object_unref (xception);
xception = NULL;
}
if (xception2 != NULL) {
g_object_unref (xception2);
xception = NULL;
}
g_clear_object (&xception);
g_clear_object (&xception2);
if (error != NULL) {
g_error_free (error);
@ -1432,11 +1646,8 @@ main (int argc, char **argv)
printf (" {%u, {\"%s\"}}\n", int32, string);
g_free (string);
g_object_unref (inner_xtruct_in);
inner_xtruct_in = NULL;
g_object_unref (xception2);
xception2 = NULL;
g_clear_object (&inner_xtruct_in);
g_clear_object (&xception2);
g_error_free (error);
error = NULL;
@ -1445,22 +1656,15 @@ main (int argc, char **argv)
printf (" result\nFAILURE\n");
fail_count++;
if (xception != NULL) {
g_object_unref (xception);
xception = NULL;
}
if (xception2 != NULL) {
g_object_unref (xception2);
xception = NULL;
}
g_clear_object (&xception);
g_clear_object (&xception2);
if (error != NULL) {
g_error_free (error);
error = NULL;
}
}
g_object_unref (xtruct_in);
g_clear_object (&xtruct_in);
printf ("testClient.testMultiException(\"success\", \"test 3\") =>");
xtruct_in = g_object_new (T_TEST_TYPE_XTRUCT, NULL);
@ -1483,22 +1687,15 @@ main (int argc, char **argv)
printf (" result\nFAILURE\n");
fail_count++;
if (xception != NULL) {
g_object_unref (xception);
xception = NULL;
}
if (xception2 != NULL) {
g_object_unref (xception2);
xception = NULL;
}
g_clear_object (&xception);
g_clear_object (&xception2);
if (error != NULL) {
g_error_free (error);
error = NULL;
}
}
g_object_unref (xtruct_in);
g_clear_object (&xtruct_in);
/* test oneway void */
printf ("testClient.testOneway(1) =>");
@ -1584,6 +1781,7 @@ main (int argc, char **argv)
/* All done---output statistics */
puts ("\nAll tests done.");
printf("Number of failures: %d\n", fail_count);
time_avg_usec = time_total_usec / num_tests;
@ -1591,10 +1789,16 @@ main (int argc, char **argv)
printf ("Max time: %" PRIu64 " us\n", time_max_usec);
printf ("Avg time: %" PRIu64 " us\n", time_avg_usec);
g_object_unref (test_client);
g_object_unref (protocol);
g_object_unref (transport);
g_free (host);
g_clear_object(&second_service);
g_clear_object(&protocol2);
g_clear_object(&test_client);
g_clear_object(&protocol);
g_clear_object(&transport);
g_clear_object(&socket);
if (ssl) {
thrift_ssl_socket_finalize_openssl();
}
return fail_count;
}

View file

@ -23,6 +23,7 @@
#include <string.h>
#include <thrift/c_glib/thrift.h>
#include <thrift/c_glib/processor/thrift_multiplexed_processor.h>
#include <thrift/c_glib/protocol/thrift_binary_protocol_factory.h>
#include <thrift/c_glib/protocol/thrift_compact_protocol_factory.h>
#include <thrift/c_glib/server/thrift_server.h>
@ -37,8 +38,10 @@
#include <thrift/c_glib/transport/thrift_transport_factory.h>
#include "../gen-c_glib/t_test_thrift_test.h"
#include "../gen-c_glib/t_test_second_service.h"
#include "thrift_test_handler.h"
#include "thrift_second_service_handler.h"
/* Our server object, declared globally so it is accessible within the SIGINT
signal handler */
@ -96,7 +99,10 @@ main (int argc, char **argv)
GType protocol_factory_type = THRIFT_TYPE_BINARY_PROTOCOL_FACTORY;
TTestThriftTestHandler *handler;
TTestThriftTestHandler *handler_second_service = NULL;
ThriftProcessor *processor;
ThriftProcessor *processor_test = NULL;
ThriftProcessor *processor_second_service = NULL;
ThriftServerTransport *server_transport;
ThriftTransportFactory *transport_factory;
ThriftProtocolFactory *protocol_factory;
@ -138,6 +144,13 @@ main (int argc, char **argv)
protocol_factory_type = THRIFT_TYPE_COMPACT_PROTOCOL_FACTORY;
protocol_name = "compact";
}
else if (strncmp (protocol_option, "multi", 6) == 0) {
protocol_name = "binary:multi";
}
else if (strncmp (protocol_option, "multic", 7) == 0) {
protocol_factory_type = THRIFT_TYPE_COMPACT_PROTOCOL_FACTORY;
protocol_name = "compact:multic";
}
else if (strncmp (protocol_option, "binary", 7) != 0) {
fprintf (stderr, "Unknown protocol type %s\n", protocol_option);
options_valid = FALSE;
@ -161,16 +174,57 @@ main (int argc, char **argv)
/* Establish all our connection objects */
handler = g_object_new (TYPE_THRIFT_TEST_HANDLER,
NULL);
processor = g_object_new (T_TEST_TYPE_THRIFT_TEST_PROCESSOR,
"handler", handler,
NULL);
if(strstr(protocol_name, ":multi")){
/* When a multiplexed processor is involved the handler is not
registered as usual. We create the processor and the real
processor is registered. Multiple processors can be registered
at once. This is why we don't have a constructor property */
processor = g_object_new (THRIFT_TYPE_MULTIPLEXED_PROCESSOR,
NULL);
handler_second_service = g_object_new (TYPE_SECOND_SERVICE_HANDLER,
NULL);
processor_test = g_object_new (T_TEST_TYPE_THRIFT_TEST_PROCESSOR,
"handler", handler,
NULL);
processor_second_service = g_object_new (T_TEST_TYPE_SECOND_SERVICE_PROCESSOR,
"handler", handler_second_service,
NULL);
/* We register a test processor with Multiplexed name ThriftTest */
if(!thrift_multiplexed_processor_register_processor(processor,
"ThriftTest", processor_test,
&error)){
g_message ("thrift_server_serve: %s",
error != NULL ? error->message : "(null)");
g_clear_error (&error);
}
/* We register a second test processor with Multiplexed name SecondService
* we are responsible of freeing the processor when it's not used anymore */
if(!thrift_multiplexed_processor_register_processor(processor,
"SecondService", processor_second_service,
&error)){
g_message ("thrift_server_serve: %s",
error != NULL ? error->message : "(null)");
g_clear_error (&error);
}
}else{
processor = g_object_new (T_TEST_TYPE_THRIFT_TEST_PROCESSOR,
"handler", handler,
NULL);
}
server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
"port", port,
NULL);
transport_factory = g_object_new (transport_factory_type,
NULL);
if (strncmp (protocol_name, "compact", 8) == 0) {
if (strstr (protocol_name, "compact") != NULL) {
protocol_factory = g_object_new (protocol_factory_type,
"string_limit", string_limit,
"container_limit", container_limit,
@ -222,6 +276,15 @@ main (int argc, char **argv)
g_object_unref (server_transport);
g_object_unref (processor);
g_object_unref (handler);
if(handler_second_service){
g_object_unref (handler_second_service);
}
if(processor_test){
g_object_unref (processor_test);
}
if(processor_second_service){
g_object_unref (processor_second_service);
}
return 0;
}

View file

@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <thrift/c_glib/thrift.h>
#include <thrift/c_glib/thrift_application_exception.h>
#include "thrift_second_service_handler.h"
/* A handler that implements the TTestSecondServiceIf interface */
G_DEFINE_TYPE (SecondServiceHandler,
second_service_handler,
T_TEST_TYPE_SECOND_SERVICE_HANDLER);
gboolean
second_service_handler_secondtest_string (TTestSecondServiceIf *iface,
gchar **_return,
const gchar *thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
gchar buffer[256];
printf ("testSecondServiceMultiplexSecondTestString(\"%s\")\n", thing);
snprintf(buffer, 255, "testString(\"%s\")", thing);
*_return = g_strdup (buffer);
return TRUE;
}
static void
second_service_handler_init (SecondServiceHandler *self)
{
THRIFT_UNUSED_VAR (self);
}
static void
second_service_handler_class_init (SecondServiceHandlerClass *klass)
{
TTestSecondServiceHandlerClass *base_class =
T_TEST_SECOND_SERVICE_HANDLER_CLASS (klass);
base_class->secondtest_string =
second_service_handler_secondtest_string;
}

View file

@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _SECOND_SERVICE_HANDLER_H
#define _SECOND_SERVICE_HANDLER_H
#include <glib-object.h>
#include <stdio.h>
#include "../gen-c_glib/t_test_second_service.h"
G_BEGIN_DECLS
/* A handler that implements the TTestSecondServiceIf interface */
#define TYPE_SECOND_SERVICE_HANDLER (second_service_handler_get_type ())
#define SECOND_SERVICE_HANDLER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
TYPE_SECOND_SERVICE_HANDLER, \
SecondServiceHandler))
#define IS_SECOND_SERVICE_HANDLER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
TYPE_SECOND_SERVICE_HANDLER))
#define SECOND_SERVICE_HANDLER_CLASS(c) \
(G_TYPE_CHECK_CLASS_CAST ((c), \
TYPE_SECOND_SERVICE_HANDLER, \
SecondServiceHandlerClass))
#define IS_SECOND_SERVICE_HANDLER_CLASS(c) \
(G_TYPE_CHECK_CLASS_TYPE ((c), \
TYPE_SECOND_SERVICE_HANDLER))
#define SECOND_SERVICE_HANDLER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
TYPE_SECOND_SERVICE_HANDLER, \
SecondServiceHandlerClass))
typedef struct _SecondServiceHandler SecondServiceHandler;
typedef struct _SecondServiceHandlerClass SecondServiceHandlerClass;
struct _SecondServiceHandler {
TTestSecondServiceHandler parent;
};
struct _SecondServiceHandlerClass {
TTestSecondServiceHandlerClass parent;
};
/* Used by SECOND_SERVICE_HANDLER_GET_TYPE */
GType second_service_handler_get_type (void);
gboolean second_service_handler_blah_blah (TTestSecondServiceIf *iface, GError **error);
gboolean second_service_handler_secondtest_string (TTestSecondServiceIf *iface, gchar ** _return, const gchar * thing, GError **error);
G_END_DECLS
#endif /* _SECOND_SERVICE_HANDLER_H */