From f7430963006ad6abb9390d769135538db9889d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Komor?= Date: Wed, 14 Oct 2026 13:44:01 +0200 Subject: [PATCH] Refactor transport plugin interfaces to unify naming conventions - Renamed transport channel and function types from `GraftcodeTransportChannel` to `TransportPluginChannel` for consistency across all transport plugins. - Updated return values and error codes to use `TRANSPORT_PLUGIN_OK` and `TRANSPORT_PLUGIN_ERROR` instead of the previous `GRAFTCODE_TRANSPORT_OK` and `GRAFTCODE_TRANSPORT_ERROR`. - Adjusted function signatures in the transport plugin implementations to reflect the new naming conventions, ensuring compatibility across the codebase. --- .../TransportPluginAbi.h | 16 ++++++++-------- .../TransportPluginExports.h | 14 +++++++------- kafka/KafkaPlugin/TransportKafka.cpp | 6 +++--- kafka/KafkaPluginTest/smoke.cpp | 6 +++--- .../TransportPluginAbi.h | 16 ++++++++-------- .../TransportPluginExports.h | 14 +++++++------- pubsub/PubSubPlugin/TransportPubSub.cpp | 6 +++--- pubsub/PubSubPluginTest/PubSubTransportTests.cpp | 8 ++++---- pubsub/PubSubPluginTest/smoke.cpp | 6 +++--- .../TransportPluginAbi.h | 16 ++++++++-------- .../TransportPluginExports.h | 14 +++++++------- rabbitmq/RabbitmqPlugin/TransportRabbitMq.cpp | 6 +++--- .../RabbitMqTransportTests.cpp | 6 +++--- .../TransportPluginAbi.h | 16 ++++++++-------- .../TransportPluginExports.h | 14 +++++++------- .../ServiceBusPlugin/TransportServiceBus.cpp | 6 +++--- .../ServiceBusTransportTests.cpp | 6 +++--- .../TransportPluginAbi.h | 16 ++++++++-------- .../TransportPluginExports.h | 14 +++++++------- sqs/SqsPlugin/TransportSqs.cpp | 6 +++--- sqs/SqsPluginTest/SqsTransportTests.cpp | 8 ++++---- sqs/SqsPluginTest/smoke.cpp | 6 +++--- 22 files changed, 113 insertions(+), 113 deletions(-) diff --git a/kafka/GraftcodePluginsInterfaces/TransportPluginAbi.h b/kafka/GraftcodePluginsInterfaces/TransportPluginAbi.h index f4a486b..a4e7c6e 100644 --- a/kafka/GraftcodePluginsInterfaces/TransportPluginAbi.h +++ b/kafka/GraftcodePluginsInterfaces/TransportPluginAbi.h @@ -23,30 +23,30 @@ extern "C" { #endif -#define GRAFTCODE_TRANSPORT_OK 0 -#define GRAFTCODE_TRANSPORT_ERROR (-1) +#define TRANSPORT_PLUGIN_OK 0 +#define TRANSPORT_PLUGIN_ERROR (-1) /** Opaque transport channel owned by the plugin. */ -typedef struct GraftcodeTransportChannel GraftcodeTransportChannel; +typedef struct TransportPluginChannel TransportPluginChannel; /** * Creates a transport channel. * Returns null on failure; *errorMessage then receives a NUL-terminated message (or null). */ -typedef GraftcodeTransportChannel* (*GraftcodeCreateTransportFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); +typedef TransportPluginChannel* (*TransportPluginCreateFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); /** Destroys a channel returned by CreateTransport. */ -typedef void (*GraftcodeDestroyTransportFn)(GraftcodeTransportChannel* channel); +typedef void (*TransportPluginDestroyFn)(TransportPluginChannel* channel); /** * Sends a request and returns its response. May be called concurrently on one channel. - * On GRAFTCODE_TRANSPORT_OK, *response and *responseLen hold the response (*response may be null when the length is 0). + * On TRANSPORT_PLUGIN_OK, *response and *responseLen hold the response (*response may be null when the length is 0). * Otherwise they hold a NUL-terminated error message and its length without the terminator. */ -typedef int32_t (*GraftcodeTransportSendCommandFn)(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); +typedef int32_t (*TransportPluginSendCommandFn)(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); /** Releases a buffer returned by the plugin. */ -typedef void (*GraftcodeTransportFreeBufferFn)(void* buffer); +typedef void (*TransportPluginFreeBufferFn)(void* buffer); #ifdef __cplusplus } diff --git a/kafka/GraftcodePluginsInterfaces/TransportPluginExports.h b/kafka/GraftcodePluginsInterfaces/TransportPluginExports.h index 0ea252d..8774d7b 100644 --- a/kafka/GraftcodePluginsInterfaces/TransportPluginExports.h +++ b/kafka/GraftcodePluginsInterfaces/TransportPluginExports.h @@ -39,7 +39,7 @@ namespace Graftcode::Plugins::TransportAbi } template - GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage) + TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage) { if (errorMessage != nullptr) { *errorMessage = nullptr; @@ -47,7 +47,7 @@ namespace Graftcode::Plugins::TransportAbi std::string error; try { ITransport* transport = factory(); - return reinterpret_cast(transport); + return reinterpret_cast(transport); } catch (const std::exception& e) { error = e.what(); @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi return nullptr; } - inline void DestroyTransport(GraftcodeTransportChannel* channel) + inline void DestroyTransport(TransportPluginChannel* channel) { delete reinterpret_cast(channel); } inline int32_t SendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { if (response == nullptr || responseLen == nullptr) { - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } *response = nullptr; *responseLen = 0; @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = buffer; *responseLen = static_cast(result.size()); - return GRAFTCODE_TRANSPORT_OK; + return TRANSPORT_PLUGIN_OK; } catch (const std::exception& e) { error = e.what(); @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = CopyBuffer(error.data(), error.size()); *responseLen = *response != nullptr ? static_cast(error.size()) : 0; - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } inline void FreeBuffer(void* buffer) diff --git a/kafka/KafkaPlugin/TransportKafka.cpp b/kafka/KafkaPlugin/TransportKafka.cpp index e6e6332..55a0fd5 100644 --- a/kafka/KafkaPlugin/TransportKafka.cpp +++ b/kafka/KafkaPlugin/TransportKafka.cpp @@ -79,15 +79,15 @@ std::vector TransportKafka::SendCommand(byte* messageByteArray, int32_t me return response; } -KAFKA_PLUGIN_EXPORT GraftcodeTransportChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) { +KAFKA_PLUGIN_EXPORT TransportPluginChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) { return Graftcode::Plugins::TransportAbi::CreateTransport([&] { return new TransportKafka(ipAddress, port, configSource); }, errorMessage); } -KAFKA_PLUGIN_EXPORT void DestroyTransport(GraftcodeTransportChannel* channel) { +KAFKA_PLUGIN_EXPORT void DestroyTransport(TransportPluginChannel* channel) { Graftcode::Plugins::TransportAbi::DestroyTransport(channel); } -KAFKA_PLUGIN_EXPORT int32_t TransportSendCommand(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { +KAFKA_PLUGIN_EXPORT int32_t TransportSendCommand(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { return Graftcode::Plugins::TransportAbi::SendCommand(channel, message, messageLen, response, responseLen); } diff --git a/kafka/KafkaPluginTest/smoke.cpp b/kafka/KafkaPluginTest/smoke.cpp index 2db7bac..4338b52 100644 --- a/kafka/KafkaPluginTest/smoke.cpp +++ b/kafka/KafkaPluginTest/smoke.cpp @@ -12,9 +12,9 @@ KAFKA_PLUGIN_IMPORT GraftcodeGateway::IServer* CreateServer(); KAFKA_PLUGIN_IMPORT void DestroyServer(GraftcodeGateway::IServer* server); -KAFKA_PLUGIN_IMPORT GraftcodeTransportChannel* CreateTransport( +KAFKA_PLUGIN_IMPORT TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -KAFKA_PLUGIN_IMPORT void DestroyTransport(GraftcodeTransportChannel* channel); +KAFKA_PLUGIN_IMPORT void DestroyTransport(TransportPluginChannel* channel); KAFKA_PLUGIN_IMPORT void TransportFreeBuffer(void* buffer); static bool g_processCalled = false; @@ -46,7 +46,7 @@ int main() { DestroyServer(server); char* errorMessage = nullptr; - GraftcodeTransportChannel* transport = + TransportPluginChannel* transport = CreateTransport("127.0.0.1", 0, cfg, &errorMessage); if (transport == nullptr) { std::printf("FAIL: CreateTransport returned null: %s\n", errorMessage != nullptr ? errorMessage : ""); diff --git a/pubsub/GraftcodePluginsInterfaces/TransportPluginAbi.h b/pubsub/GraftcodePluginsInterfaces/TransportPluginAbi.h index f4a486b..a4e7c6e 100644 --- a/pubsub/GraftcodePluginsInterfaces/TransportPluginAbi.h +++ b/pubsub/GraftcodePluginsInterfaces/TransportPluginAbi.h @@ -23,30 +23,30 @@ extern "C" { #endif -#define GRAFTCODE_TRANSPORT_OK 0 -#define GRAFTCODE_TRANSPORT_ERROR (-1) +#define TRANSPORT_PLUGIN_OK 0 +#define TRANSPORT_PLUGIN_ERROR (-1) /** Opaque transport channel owned by the plugin. */ -typedef struct GraftcodeTransportChannel GraftcodeTransportChannel; +typedef struct TransportPluginChannel TransportPluginChannel; /** * Creates a transport channel. * Returns null on failure; *errorMessage then receives a NUL-terminated message (or null). */ -typedef GraftcodeTransportChannel* (*GraftcodeCreateTransportFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); +typedef TransportPluginChannel* (*TransportPluginCreateFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); /** Destroys a channel returned by CreateTransport. */ -typedef void (*GraftcodeDestroyTransportFn)(GraftcodeTransportChannel* channel); +typedef void (*TransportPluginDestroyFn)(TransportPluginChannel* channel); /** * Sends a request and returns its response. May be called concurrently on one channel. - * On GRAFTCODE_TRANSPORT_OK, *response and *responseLen hold the response (*response may be null when the length is 0). + * On TRANSPORT_PLUGIN_OK, *response and *responseLen hold the response (*response may be null when the length is 0). * Otherwise they hold a NUL-terminated error message and its length without the terminator. */ -typedef int32_t (*GraftcodeTransportSendCommandFn)(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); +typedef int32_t (*TransportPluginSendCommandFn)(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); /** Releases a buffer returned by the plugin. */ -typedef void (*GraftcodeTransportFreeBufferFn)(void* buffer); +typedef void (*TransportPluginFreeBufferFn)(void* buffer); #ifdef __cplusplus } diff --git a/pubsub/GraftcodePluginsInterfaces/TransportPluginExports.h b/pubsub/GraftcodePluginsInterfaces/TransportPluginExports.h index 0ea252d..8774d7b 100644 --- a/pubsub/GraftcodePluginsInterfaces/TransportPluginExports.h +++ b/pubsub/GraftcodePluginsInterfaces/TransportPluginExports.h @@ -39,7 +39,7 @@ namespace Graftcode::Plugins::TransportAbi } template - GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage) + TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage) { if (errorMessage != nullptr) { *errorMessage = nullptr; @@ -47,7 +47,7 @@ namespace Graftcode::Plugins::TransportAbi std::string error; try { ITransport* transport = factory(); - return reinterpret_cast(transport); + return reinterpret_cast(transport); } catch (const std::exception& e) { error = e.what(); @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi return nullptr; } - inline void DestroyTransport(GraftcodeTransportChannel* channel) + inline void DestroyTransport(TransportPluginChannel* channel) { delete reinterpret_cast(channel); } inline int32_t SendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { if (response == nullptr || responseLen == nullptr) { - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } *response = nullptr; *responseLen = 0; @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = buffer; *responseLen = static_cast(result.size()); - return GRAFTCODE_TRANSPORT_OK; + return TRANSPORT_PLUGIN_OK; } catch (const std::exception& e) { error = e.what(); @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = CopyBuffer(error.data(), error.size()); *responseLen = *response != nullptr ? static_cast(error.size()) : 0; - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } inline void FreeBuffer(void* buffer) diff --git a/pubsub/PubSubPlugin/TransportPubSub.cpp b/pubsub/PubSubPlugin/TransportPubSub.cpp index ecddfa4..5464f69 100644 --- a/pubsub/PubSubPlugin/TransportPubSub.cpp +++ b/pubsub/PubSubPlugin/TransportPubSub.cpp @@ -54,7 +54,7 @@ namespace Graftcode::Plugins::PubSub #define PUBSUB_PLUGIN_EXPORT extern "C" #endif -PUBSUB_PLUGIN_EXPORT GraftcodeTransportChannel* +PUBSUB_PLUGIN_EXPORT TransportPluginChannel* CreateTransport( const char*, unsigned short, @@ -67,13 +67,13 @@ CreateTransport( } PUBSUB_PLUGIN_EXPORT void DestroyTransport( - GraftcodeTransportChannel* channel) + TransportPluginChannel* channel) { Graftcode::Plugins::TransportAbi::DestroyTransport(channel); } PUBSUB_PLUGIN_EXPORT int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, diff --git a/pubsub/PubSubPluginTest/PubSubTransportTests.cpp b/pubsub/PubSubPluginTest/PubSubTransportTests.cpp index 1aaf99b..4ec2516 100644 --- a/pubsub/PubSubPluginTest/PubSubTransportTests.cpp +++ b/pubsub/PubSubPluginTest/PubSubTransportTests.cpp @@ -25,14 +25,14 @@ #include #include -extern "C" GraftcodeTransportChannel* CreateTransport( +extern "C" TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -extern "C" void DestroyTransport(GraftcodeTransportChannel* channel); +extern "C" void DestroyTransport(TransportPluginChannel* channel); extern "C" int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, @@ -509,7 +509,7 @@ TEST(PubSubTransport, FactoryCreatesAndDestroysTransport) int32_t responseLen = 0; EXPECT_EQ( TransportSendCommand(channel, nullptr, length, &response, &responseLen), - GRAFTCODE_TRANSPORT_ERROR); + TRANSPORT_PLUGIN_ERROR); ASSERT_NE(response, nullptr); EXPECT_EQ( std::string(reinterpret_cast(response), responseLen), diff --git a/pubsub/PubSubPluginTest/smoke.cpp b/pubsub/PubSubPluginTest/smoke.cpp index 9794e88..ff9b44b 100644 --- a/pubsub/PubSubPluginTest/smoke.cpp +++ b/pubsub/PubSubPluginTest/smoke.cpp @@ -11,9 +11,9 @@ PUBSUB_PLUGIN_IMPORT GraftcodeGateway::IServer* CreateServer(); PUBSUB_PLUGIN_IMPORT void DestroyServer(GraftcodeGateway::IServer* server); -PUBSUB_PLUGIN_IMPORT GraftcodeTransportChannel* CreateTransport( +PUBSUB_PLUGIN_IMPORT TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -PUBSUB_PLUGIN_IMPORT void DestroyTransport(GraftcodeTransportChannel* channel); +PUBSUB_PLUGIN_IMPORT void DestroyTransport(TransportPluginChannel* channel); PUBSUB_PLUGIN_IMPORT void TransportFreeBuffer(void* buffer); static bool smokeProcess( @@ -51,7 +51,7 @@ int main() DestroyServer(server); char* errorMessage = nullptr; - GraftcodeTransportChannel* transport = + TransportPluginChannel* transport = CreateTransport(nullptr, 0, config, &errorMessage); if (transport == nullptr) { std::printf("FAIL: CreateTransport returned null: %s\n", errorMessage != nullptr ? errorMessage : ""); diff --git a/rabbitmq/GraftcodePluginsInterfaces/TransportPluginAbi.h b/rabbitmq/GraftcodePluginsInterfaces/TransportPluginAbi.h index f4a486b..a4e7c6e 100644 --- a/rabbitmq/GraftcodePluginsInterfaces/TransportPluginAbi.h +++ b/rabbitmq/GraftcodePluginsInterfaces/TransportPluginAbi.h @@ -23,30 +23,30 @@ extern "C" { #endif -#define GRAFTCODE_TRANSPORT_OK 0 -#define GRAFTCODE_TRANSPORT_ERROR (-1) +#define TRANSPORT_PLUGIN_OK 0 +#define TRANSPORT_PLUGIN_ERROR (-1) /** Opaque transport channel owned by the plugin. */ -typedef struct GraftcodeTransportChannel GraftcodeTransportChannel; +typedef struct TransportPluginChannel TransportPluginChannel; /** * Creates a transport channel. * Returns null on failure; *errorMessage then receives a NUL-terminated message (or null). */ -typedef GraftcodeTransportChannel* (*GraftcodeCreateTransportFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); +typedef TransportPluginChannel* (*TransportPluginCreateFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); /** Destroys a channel returned by CreateTransport. */ -typedef void (*GraftcodeDestroyTransportFn)(GraftcodeTransportChannel* channel); +typedef void (*TransportPluginDestroyFn)(TransportPluginChannel* channel); /** * Sends a request and returns its response. May be called concurrently on one channel. - * On GRAFTCODE_TRANSPORT_OK, *response and *responseLen hold the response (*response may be null when the length is 0). + * On TRANSPORT_PLUGIN_OK, *response and *responseLen hold the response (*response may be null when the length is 0). * Otherwise they hold a NUL-terminated error message and its length without the terminator. */ -typedef int32_t (*GraftcodeTransportSendCommandFn)(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); +typedef int32_t (*TransportPluginSendCommandFn)(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); /** Releases a buffer returned by the plugin. */ -typedef void (*GraftcodeTransportFreeBufferFn)(void* buffer); +typedef void (*TransportPluginFreeBufferFn)(void* buffer); #ifdef __cplusplus } diff --git a/rabbitmq/GraftcodePluginsInterfaces/TransportPluginExports.h b/rabbitmq/GraftcodePluginsInterfaces/TransportPluginExports.h index 0ea252d..8774d7b 100644 --- a/rabbitmq/GraftcodePluginsInterfaces/TransportPluginExports.h +++ b/rabbitmq/GraftcodePluginsInterfaces/TransportPluginExports.h @@ -39,7 +39,7 @@ namespace Graftcode::Plugins::TransportAbi } template - GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage) + TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage) { if (errorMessage != nullptr) { *errorMessage = nullptr; @@ -47,7 +47,7 @@ namespace Graftcode::Plugins::TransportAbi std::string error; try { ITransport* transport = factory(); - return reinterpret_cast(transport); + return reinterpret_cast(transport); } catch (const std::exception& e) { error = e.what(); @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi return nullptr; } - inline void DestroyTransport(GraftcodeTransportChannel* channel) + inline void DestroyTransport(TransportPluginChannel* channel) { delete reinterpret_cast(channel); } inline int32_t SendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { if (response == nullptr || responseLen == nullptr) { - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } *response = nullptr; *responseLen = 0; @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = buffer; *responseLen = static_cast(result.size()); - return GRAFTCODE_TRANSPORT_OK; + return TRANSPORT_PLUGIN_OK; } catch (const std::exception& e) { error = e.what(); @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = CopyBuffer(error.data(), error.size()); *responseLen = *response != nullptr ? static_cast(error.size()) : 0; - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } inline void FreeBuffer(void* buffer) diff --git a/rabbitmq/RabbitmqPlugin/TransportRabbitMq.cpp b/rabbitmq/RabbitmqPlugin/TransportRabbitMq.cpp index 3771eaa..ba5bfec 100644 --- a/rabbitmq/RabbitmqPlugin/TransportRabbitMq.cpp +++ b/rabbitmq/RabbitmqPlugin/TransportRabbitMq.cpp @@ -51,7 +51,7 @@ std::vector TransportRabbitMq::SendCommand(byte* messageByteArray, int32_t #define RABBITMQ_PLUGIN_EXPORT extern "C" #endif -RABBITMQ_PLUGIN_EXPORT GraftcodeTransportChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) +RABBITMQ_PLUGIN_EXPORT TransportPluginChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) { return Graftcode::Plugins::TransportAbi::CreateTransport( [&] { @@ -63,12 +63,12 @@ RABBITMQ_PLUGIN_EXPORT GraftcodeTransportChannel* CreateTransport(const char* ip errorMessage); } -RABBITMQ_PLUGIN_EXPORT void DestroyTransport(GraftcodeTransportChannel* channel) +RABBITMQ_PLUGIN_EXPORT void DestroyTransport(TransportPluginChannel* channel) { Graftcode::Plugins::TransportAbi::DestroyTransport(channel); } -RABBITMQ_PLUGIN_EXPORT int32_t TransportSendCommand(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) +RABBITMQ_PLUGIN_EXPORT int32_t TransportSendCommand(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { return Graftcode::Plugins::TransportAbi::SendCommand(channel, message, messageLen, response, responseLen); } diff --git a/rabbitmq/RabbitmqPluginTest/RabbitMqTransportTests.cpp b/rabbitmq/RabbitmqPluginTest/RabbitMqTransportTests.cpp index cf3409d..8a91ce5 100644 --- a/rabbitmq/RabbitmqPluginTest/RabbitMqTransportTests.cpp +++ b/rabbitmq/RabbitmqPluginTest/RabbitMqTransportTests.cpp @@ -15,14 +15,14 @@ #include #include -extern "C" GraftcodeTransportChannel* CreateTransport( +extern "C" TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -extern "C" void DestroyTransport(GraftcodeTransportChannel* channel); +extern "C" void DestroyTransport(TransportPluginChannel* channel); extern "C" int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, diff --git a/servicebus/GraftcodePluginsInterfaces/TransportPluginAbi.h b/servicebus/GraftcodePluginsInterfaces/TransportPluginAbi.h index f4a486b..a4e7c6e 100644 --- a/servicebus/GraftcodePluginsInterfaces/TransportPluginAbi.h +++ b/servicebus/GraftcodePluginsInterfaces/TransportPluginAbi.h @@ -23,30 +23,30 @@ extern "C" { #endif -#define GRAFTCODE_TRANSPORT_OK 0 -#define GRAFTCODE_TRANSPORT_ERROR (-1) +#define TRANSPORT_PLUGIN_OK 0 +#define TRANSPORT_PLUGIN_ERROR (-1) /** Opaque transport channel owned by the plugin. */ -typedef struct GraftcodeTransportChannel GraftcodeTransportChannel; +typedef struct TransportPluginChannel TransportPluginChannel; /** * Creates a transport channel. * Returns null on failure; *errorMessage then receives a NUL-terminated message (or null). */ -typedef GraftcodeTransportChannel* (*GraftcodeCreateTransportFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); +typedef TransportPluginChannel* (*TransportPluginCreateFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); /** Destroys a channel returned by CreateTransport. */ -typedef void (*GraftcodeDestroyTransportFn)(GraftcodeTransportChannel* channel); +typedef void (*TransportPluginDestroyFn)(TransportPluginChannel* channel); /** * Sends a request and returns its response. May be called concurrently on one channel. - * On GRAFTCODE_TRANSPORT_OK, *response and *responseLen hold the response (*response may be null when the length is 0). + * On TRANSPORT_PLUGIN_OK, *response and *responseLen hold the response (*response may be null when the length is 0). * Otherwise they hold a NUL-terminated error message and its length without the terminator. */ -typedef int32_t (*GraftcodeTransportSendCommandFn)(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); +typedef int32_t (*TransportPluginSendCommandFn)(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); /** Releases a buffer returned by the plugin. */ -typedef void (*GraftcodeTransportFreeBufferFn)(void* buffer); +typedef void (*TransportPluginFreeBufferFn)(void* buffer); #ifdef __cplusplus } diff --git a/servicebus/GraftcodePluginsInterfaces/TransportPluginExports.h b/servicebus/GraftcodePluginsInterfaces/TransportPluginExports.h index 0ea252d..8774d7b 100644 --- a/servicebus/GraftcodePluginsInterfaces/TransportPluginExports.h +++ b/servicebus/GraftcodePluginsInterfaces/TransportPluginExports.h @@ -39,7 +39,7 @@ namespace Graftcode::Plugins::TransportAbi } template - GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage) + TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage) { if (errorMessage != nullptr) { *errorMessage = nullptr; @@ -47,7 +47,7 @@ namespace Graftcode::Plugins::TransportAbi std::string error; try { ITransport* transport = factory(); - return reinterpret_cast(transport); + return reinterpret_cast(transport); } catch (const std::exception& e) { error = e.what(); @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi return nullptr; } - inline void DestroyTransport(GraftcodeTransportChannel* channel) + inline void DestroyTransport(TransportPluginChannel* channel) { delete reinterpret_cast(channel); } inline int32_t SendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { if (response == nullptr || responseLen == nullptr) { - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } *response = nullptr; *responseLen = 0; @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = buffer; *responseLen = static_cast(result.size()); - return GRAFTCODE_TRANSPORT_OK; + return TRANSPORT_PLUGIN_OK; } catch (const std::exception& e) { error = e.what(); @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = CopyBuffer(error.data(), error.size()); *responseLen = *response != nullptr ? static_cast(error.size()) : 0; - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } inline void FreeBuffer(void* buffer) diff --git a/servicebus/ServiceBusPlugin/TransportServiceBus.cpp b/servicebus/ServiceBusPlugin/TransportServiceBus.cpp index 03b34c8..aeccc89 100644 --- a/servicebus/ServiceBusPlugin/TransportServiceBus.cpp +++ b/servicebus/ServiceBusPlugin/TransportServiceBus.cpp @@ -51,7 +51,7 @@ std::vector TransportServiceBus::SendCommand(byte* messageByteArray, int32 #define SERVICEBUS_PLUGIN_EXPORT extern "C" #endif -SERVICEBUS_PLUGIN_EXPORT GraftcodeTransportChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) +SERVICEBUS_PLUGIN_EXPORT TransportPluginChannel* CreateTransport(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage) { return Graftcode::Plugins::TransportAbi::CreateTransport( [&] { @@ -63,12 +63,12 @@ SERVICEBUS_PLUGIN_EXPORT GraftcodeTransportChannel* CreateTransport(const char* errorMessage); } -SERVICEBUS_PLUGIN_EXPORT void DestroyTransport(GraftcodeTransportChannel* channel) +SERVICEBUS_PLUGIN_EXPORT void DestroyTransport(TransportPluginChannel* channel) { Graftcode::Plugins::TransportAbi::DestroyTransport(channel); } -SERVICEBUS_PLUGIN_EXPORT int32_t TransportSendCommand(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) +SERVICEBUS_PLUGIN_EXPORT int32_t TransportSendCommand(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { return Graftcode::Plugins::TransportAbi::SendCommand(channel, message, messageLen, response, responseLen); } diff --git a/servicebus/ServiceBusPluginTest/ServiceBusTransportTests.cpp b/servicebus/ServiceBusPluginTest/ServiceBusTransportTests.cpp index febbaac..0e3ed2f 100644 --- a/servicebus/ServiceBusPluginTest/ServiceBusTransportTests.cpp +++ b/servicebus/ServiceBusPluginTest/ServiceBusTransportTests.cpp @@ -17,14 +17,14 @@ #include #include -extern "C" GraftcodeTransportChannel* CreateTransport( +extern "C" TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -extern "C" void DestroyTransport(GraftcodeTransportChannel* channel); +extern "C" void DestroyTransport(TransportPluginChannel* channel); extern "C" int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, diff --git a/sqs/GraftcodePluginsInterfaces/TransportPluginAbi.h b/sqs/GraftcodePluginsInterfaces/TransportPluginAbi.h index f4a486b..a4e7c6e 100644 --- a/sqs/GraftcodePluginsInterfaces/TransportPluginAbi.h +++ b/sqs/GraftcodePluginsInterfaces/TransportPluginAbi.h @@ -23,30 +23,30 @@ extern "C" { #endif -#define GRAFTCODE_TRANSPORT_OK 0 -#define GRAFTCODE_TRANSPORT_ERROR (-1) +#define TRANSPORT_PLUGIN_OK 0 +#define TRANSPORT_PLUGIN_ERROR (-1) /** Opaque transport channel owned by the plugin. */ -typedef struct GraftcodeTransportChannel GraftcodeTransportChannel; +typedef struct TransportPluginChannel TransportPluginChannel; /** * Creates a transport channel. * Returns null on failure; *errorMessage then receives a NUL-terminated message (or null). */ -typedef GraftcodeTransportChannel* (*GraftcodeCreateTransportFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); +typedef TransportPluginChannel* (*TransportPluginCreateFn)(const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); /** Destroys a channel returned by CreateTransport. */ -typedef void (*GraftcodeDestroyTransportFn)(GraftcodeTransportChannel* channel); +typedef void (*TransportPluginDestroyFn)(TransportPluginChannel* channel); /** * Sends a request and returns its response. May be called concurrently on one channel. - * On GRAFTCODE_TRANSPORT_OK, *response and *responseLen hold the response (*response may be null when the length is 0). + * On TRANSPORT_PLUGIN_OK, *response and *responseLen hold the response (*response may be null when the length is 0). * Otherwise they hold a NUL-terminated error message and its length without the terminator. */ -typedef int32_t (*GraftcodeTransportSendCommandFn)(GraftcodeTransportChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); +typedef int32_t (*TransportPluginSendCommandFn)(TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen); /** Releases a buffer returned by the plugin. */ -typedef void (*GraftcodeTransportFreeBufferFn)(void* buffer); +typedef void (*TransportPluginFreeBufferFn)(void* buffer); #ifdef __cplusplus } diff --git a/sqs/GraftcodePluginsInterfaces/TransportPluginExports.h b/sqs/GraftcodePluginsInterfaces/TransportPluginExports.h index 0ea252d..8774d7b 100644 --- a/sqs/GraftcodePluginsInterfaces/TransportPluginExports.h +++ b/sqs/GraftcodePluginsInterfaces/TransportPluginExports.h @@ -39,7 +39,7 @@ namespace Graftcode::Plugins::TransportAbi } template - GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage) + TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage) { if (errorMessage != nullptr) { *errorMessage = nullptr; @@ -47,7 +47,7 @@ namespace Graftcode::Plugins::TransportAbi std::string error; try { ITransport* transport = factory(); - return reinterpret_cast(transport); + return reinterpret_cast(transport); } catch (const std::exception& e) { error = e.what(); @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi return nullptr; } - inline void DestroyTransport(GraftcodeTransportChannel* channel) + inline void DestroyTransport(TransportPluginChannel* channel) { delete reinterpret_cast(channel); } inline int32_t SendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, int32_t* responseLen) { if (response == nullptr || responseLen == nullptr) { - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } *response = nullptr; *responseLen = 0; @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = buffer; *responseLen = static_cast(result.size()); - return GRAFTCODE_TRANSPORT_OK; + return TRANSPORT_PLUGIN_OK; } catch (const std::exception& e) { error = e.what(); @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi } *response = CopyBuffer(error.data(), error.size()); *responseLen = *response != nullptr ? static_cast(error.size()) : 0; - return GRAFTCODE_TRANSPORT_ERROR; + return TRANSPORT_PLUGIN_ERROR; } inline void FreeBuffer(void* buffer) diff --git a/sqs/SqsPlugin/TransportSqs.cpp b/sqs/SqsPlugin/TransportSqs.cpp index c61e00e..28cdd44 100644 --- a/sqs/SqsPlugin/TransportSqs.cpp +++ b/sqs/SqsPlugin/TransportSqs.cpp @@ -58,7 +58,7 @@ std::vector TransportSqs::SendCommand( #define SQS_PLUGIN_EXPORT extern "C" #endif -SQS_PLUGIN_EXPORT GraftcodeTransportChannel* +SQS_PLUGIN_EXPORT TransportPluginChannel* CreateTransport( const char*, unsigned short, @@ -71,13 +71,13 @@ CreateTransport( } SQS_PLUGIN_EXPORT void DestroyTransport( - GraftcodeTransportChannel* channel) + TransportPluginChannel* channel) { Graftcode::Plugins::TransportAbi::DestroyTransport(channel); } SQS_PLUGIN_EXPORT int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, diff --git a/sqs/SqsPluginTest/SqsTransportTests.cpp b/sqs/SqsPluginTest/SqsTransportTests.cpp index 0d6d129..a77cc2e 100644 --- a/sqs/SqsPluginTest/SqsTransportTests.cpp +++ b/sqs/SqsPluginTest/SqsTransportTests.cpp @@ -23,14 +23,14 @@ #include #include -extern "C" GraftcodeTransportChannel* CreateTransport( +extern "C" TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -extern "C" void DestroyTransport(GraftcodeTransportChannel* channel); +extern "C" void DestroyTransport(TransportPluginChannel* channel); extern "C" int32_t TransportSendCommand( - GraftcodeTransportChannel* channel, + TransportPluginChannel* channel, const unsigned char* message, int32_t messageLen, unsigned char** response, @@ -359,7 +359,7 @@ TEST(SqsTransport, FactoryCreatesAndDestroysTransport) int32_t responseLen = 0; EXPECT_EQ( TransportSendCommand(channel, nullptr, length, &response, &responseLen), - GRAFTCODE_TRANSPORT_ERROR); + TRANSPORT_PLUGIN_ERROR); ASSERT_NE(response, nullptr); EXPECT_EQ( std::string(reinterpret_cast(response), responseLen), diff --git a/sqs/SqsPluginTest/smoke.cpp b/sqs/SqsPluginTest/smoke.cpp index bb03403..290a14e 100644 --- a/sqs/SqsPluginTest/smoke.cpp +++ b/sqs/SqsPluginTest/smoke.cpp @@ -11,9 +11,9 @@ SQS_PLUGIN_IMPORT GraftcodeGateway::IServer* CreateServer(); SQS_PLUGIN_IMPORT void DestroyServer(GraftcodeGateway::IServer* server); -SQS_PLUGIN_IMPORT GraftcodeTransportChannel* CreateTransport( +SQS_PLUGIN_IMPORT TransportPluginChannel* CreateTransport( const char* ipAddress, unsigned short port, const char* configSource, char** errorMessage); -SQS_PLUGIN_IMPORT void DestroyTransport(GraftcodeTransportChannel* channel); +SQS_PLUGIN_IMPORT void DestroyTransport(TransportPluginChannel* channel); SQS_PLUGIN_IMPORT void TransportFreeBuffer(void* buffer); static bool smokeProcess( @@ -52,7 +52,7 @@ int main() DestroyServer(server); char* errorMessage = nullptr; - GraftcodeTransportChannel* transport = + TransportPluginChannel* transport = CreateTransport(nullptr, 0, config, &errorMessage); if (transport == nullptr) { std::printf("FAIL: CreateTransport returned null: %s\n", errorMessage != nullptr ? errorMessage : "");