0
|
1 |
/**
|
|
2 |
* Relational pipes
|
|
3 |
* Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info)
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation, version 3 of the License.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
*/
|
|
17 |
#include <vector>
|
|
18 |
#include <memory>
|
|
19 |
#include <locale>
|
|
20 |
#include <algorithm>
|
|
21 |
|
|
22 |
#include <relpipe/writer/RelationalWriter.h>
|
|
23 |
#include <relpipe/writer/RelpipeWriterException.h>
|
|
24 |
#include <relpipe/writer/AttributeMetadata.h>
|
|
25 |
#include <relpipe/writer/Factory.h>
|
|
26 |
#include <relpipe/writer/TypeId.h>
|
|
27 |
|
|
28 |
#include <relpipe/cli/CLI.h>
|
|
29 |
|
|
30 |
#include "KafkaCommand.h"
|
|
31 |
#include "Hex.h"
|
|
32 |
|
|
33 |
using namespace std;
|
|
34 |
using namespace relpipe::cli;
|
|
35 |
using namespace relpipe::writer;
|
|
36 |
|
|
37 |
namespace relpipe {
|
|
38 |
namespace in {
|
|
39 |
namespace kafka {
|
|
40 |
|
|
41 |
void KafkaCommand::process(std::shared_ptr<writer::RelationalWriter> writer, Configuration& configuration) {
|
|
42 |
vector<AttributeMetadata> metadata;
|
|
43 |
|
|
44 |
writer->startRelation(configuration.relation,{
|
|
45 |
{L"queue", TypeId::STRING},
|
|
46 |
{L"text", TypeId::STRING},
|
|
47 |
{L"data", TypeId::STRING}
|
|
48 |
}, true);
|
|
49 |
|
|
50 |
for (int i = configuration.messageCount; i > 0; i--) {
|
|
51 |
std::string message = "TODO: read message from Kafka";
|
|
52 |
writer->writeAttribute(configuration.queue);
|
|
53 |
writer->writeAttribute(Hex::toTxt(message));
|
|
54 |
writer->writeAttribute(Hex::toHex(message));
|
|
55 |
}
|
|
56 |
|
|
57 |
}
|
|
58 |
|
|
59 |
KafkaCommand::~KafkaCommand() {
|
|
60 |
}
|
|
61 |
|
|
62 |
}
|
|
63 |
}
|
|
64 |
} |