Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions kafka/GraftcodePluginsInterfaces/TransportPluginAbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions kafka/GraftcodePluginsInterfaces/TransportPluginExports.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ namespace Graftcode::Plugins::TransportAbi
}

template <typename Factory>
GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage)
TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage)
{
if (errorMessage != nullptr) {
*errorMessage = nullptr;
}
std::string error;
try {
ITransport* transport = factory();
return reinterpret_cast<GraftcodeTransportChannel*>(transport);
return reinterpret_cast<TransportPluginChannel*>(transport);
}
catch (const std::exception& e) {
error = e.what();
Expand All @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi
return nullptr;
}

inline void DestroyTransport(GraftcodeTransportChannel* channel)
inline void DestroyTransport(TransportPluginChannel* channel)
{
delete reinterpret_cast<ITransport*>(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;
Expand All @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi
}
*response = buffer;
*responseLen = static_cast<int32_t>(result.size());
return GRAFTCODE_TRANSPORT_OK;
return TRANSPORT_PLUGIN_OK;
}
catch (const std::exception& e) {
error = e.what();
Expand All @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi
}
*response = CopyBuffer(error.data(), error.size());
*responseLen = *response != nullptr ? static_cast<int32_t>(error.size()) : 0;
return GRAFTCODE_TRANSPORT_ERROR;
return TRANSPORT_PLUGIN_ERROR;
}

inline void FreeBuffer(void* buffer)
Expand Down
6 changes: 3 additions & 3 deletions kafka/KafkaPlugin/TransportKafka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ std::vector<byte> 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);
}

Expand Down
6 changes: 3 additions & 3 deletions kafka/KafkaPluginTest/smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 : "");
Expand Down
16 changes: 8 additions & 8 deletions pubsub/GraftcodePluginsInterfaces/TransportPluginAbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions pubsub/GraftcodePluginsInterfaces/TransportPluginExports.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ namespace Graftcode::Plugins::TransportAbi
}

template <typename Factory>
GraftcodeTransportChannel* CreateTransport(Factory&& factory, char** errorMessage)
TransportPluginChannel* CreateTransport(Factory&& factory, char** errorMessage)
{
if (errorMessage != nullptr) {
*errorMessage = nullptr;
}
std::string error;
try {
ITransport* transport = factory();
return reinterpret_cast<GraftcodeTransportChannel*>(transport);
return reinterpret_cast<TransportPluginChannel*>(transport);
}
catch (const std::exception& e) {
error = e.what();
Expand All @@ -61,20 +61,20 @@ namespace Graftcode::Plugins::TransportAbi
return nullptr;
}

inline void DestroyTransport(GraftcodeTransportChannel* channel)
inline void DestroyTransport(TransportPluginChannel* channel)
{
delete reinterpret_cast<ITransport*>(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;
Expand All @@ -92,7 +92,7 @@ namespace Graftcode::Plugins::TransportAbi
}
*response = buffer;
*responseLen = static_cast<int32_t>(result.size());
return GRAFTCODE_TRANSPORT_OK;
return TRANSPORT_PLUGIN_OK;
}
catch (const std::exception& e) {
error = e.what();
Expand All @@ -102,7 +102,7 @@ namespace Graftcode::Plugins::TransportAbi
}
*response = CopyBuffer(error.data(), error.size());
*responseLen = *response != nullptr ? static_cast<int32_t>(error.size()) : 0;
return GRAFTCODE_TRANSPORT_ERROR;
return TRANSPORT_PLUGIN_ERROR;
}

inline void FreeBuffer(void* buffer)
Expand Down
6 changes: 3 additions & 3 deletions pubsub/PubSubPlugin/TransportPubSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions pubsub/PubSubPluginTest/PubSubTransportTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#include <thread>
#include <vector>

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,
Expand Down Expand Up @@ -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<const char*>(response), responseLen),
Expand Down
6 changes: 3 additions & 3 deletions pubsub/PubSubPluginTest/smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 : "");
Expand Down
16 changes: 8 additions & 8 deletions rabbitmq/GraftcodePluginsInterfaces/TransportPluginAbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading
Loading