MXS-1538: Integrate CDC-Connector into MaxScale
Added the files from the repository to MaxScale. Created a new CMake function for installing development libraries.
This commit is contained in:
51
connectors/cdc-connector/examples/main.cpp
Normal file
51
connectors/cdc-connector/examples/main.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* This is an example on how to use the CDC Connector to print the keys and
|
||||
* their values.
|
||||
*/
|
||||
|
||||
#include "../cdc_connector.h"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
if (argc < 6)
|
||||
{
|
||||
std::cout << "Usage: HOST PORT USER PASSWORD DATABASE.TABLE" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Note that DATABASE.TABLE must have both database and table " << std::endl;
|
||||
std::cout << "combined together as one value with a period." << std::endl;
|
||||
std::cout << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
CDC::Connection conn(argv[1], // Host
|
||||
atoi(argv[2]), // Port
|
||||
argv[3], // User
|
||||
argv[4]); // Password
|
||||
|
||||
if (conn.connect(argv[5]))
|
||||
{
|
||||
CDC::Row row;
|
||||
|
||||
while ((row = conn.read()))
|
||||
{
|
||||
for (size_t i = 0; i < row->length(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
std::cout << ", ";
|
||||
}
|
||||
std::cout << row->key(i) << ": " << row->value(i);
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << conn.error() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user