init commit

This commit is contained in:
linguini
2026-07-13 10:34:54 +02:00
commit 26e9d8d3d0
151 changed files with 381 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
.idea/
+3
View File
@@ -0,0 +1,3 @@
[submodule "libs/rmqcpp"]
path = libs/rmqcpp
url = https://github.com/bloomberg/rmqcpp.git
+26
View File
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.20)
project(image-worker-cpp)
set(CMAKE_CXX_STANDARD 20)
add_executable(image-worker-cpp
main.cpp
src/rmq/ConnectionHandler.cpp
)
target_include_directories(image-worker-cpp PRIVATE
/usr/include
)
target_link_directories(image-worker-cpp PRIVATE
/usr/lib
)
target_link_libraries(image-worker-cpp PRIVATE
amqpcpp
pthread
dl
uv
ssl
)
+33
View File
@@ -0,0 +1,33 @@
#include "src/rmq/ConnectionHandler.hpp"
#include <iostream>
#include <amqpcpp.h>
#include <uv.h>
int main()
{
// access to the event loop
auto *loop = uv_default_loop();
// handler for libev
ConnectionHandler handler(loop);
// make a connection
AMQP::TcpConnection connection(&handler, AMQP::Address("amqps://proxmox:proxmox@mq.pseudot.org:5671/"));
// we need a channel too
AMQP::TcpChannel channel(&connection);
// create a temporary queue
channel.declareQueue("ciao-bella-cpp",AMQP::durable).onSuccess([&connection](const std::string &name, uint32_t messagecount, uint32_t consumercount) {
// report the name of the temporary queue
std::cout << "declared queue " << name << std::endl;
});
// run the loop
uv_run(loop, UV_RUN_DEFAULT);
// done
return 0;
}
@@ -0,0 +1,18 @@
#include "ConnectionHandler.hpp"
#include <iostream>
void ConnectionHandler::onConnected(AMQP::TcpConnection *connection)
{
std::cout << "TCP CONNECTED\n";
}
void ConnectionHandler::onReady(AMQP::TcpConnection *connection)
{
std::cout << "AMQP READY\n";
}
void ConnectionHandler::onError(AMQP::TcpConnection *connection, const char *message)
{
std::cerr << "AMQP error: " << message << std::endl;
}
@@ -0,0 +1,19 @@
#pragma once
#include <uv.h>
#include <amqpcpp.h>
#include <amqpcpp/libuv.h>
class ConnectionHandler : public AMQP::LibUvHandler {
public:
ConnectionHandler(uv_loop_t *loop)
: AMQP::LibUvHandler(loop)
{}
void onConnected(AMQP::TcpConnection *connection) override;
void onReady(AMQP::TcpConnection *connection) override;
void onError(AMQP::TcpConnection *connection, const char *message) override;
~ConnectionHandler() override = default;
};
+1
View File
@@ -0,0 +1 @@
.idea/
+3
View File
@@ -0,0 +1,3 @@
[submodule "libs/rmqcpp"]
path = libs/rmqcpp
url = https://github.com/bloomberg/rmqcpp.git
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.20)
project(metadata-worker-cpp)
set(CMAKE_CXX_STANDARD 20)
add_executable(metadata-worker-cpp
main.cpp
src/rmq/ConnectionHandler.cpp
)
target_include_directories(metadata-worker-cpp PRIVATE
/usr/include
)
target_link_directories(metadata-worker-cpp PRIVATE
/usr/lib
)
target_link_libraries(metadata-worker-cpp PRIVATE
amqpcpp
pthread
dl
uv
ssl
)
+33
View File
@@ -0,0 +1,33 @@
#include "src/rmq/ConnectionHandler.hpp"
#include <iostream>
#include <amqpcpp.h>
#include <uv.h>
int main()
{
// access to the event loop
auto *loop = uv_default_loop();
// handler for libev
ConnectionHandler handler(loop);
// make a connection
AMQP::TcpConnection connection(&handler, AMQP::Address("amqps://proxmox:proxmox@mq.pseudot.org:5671/"));
// we need a channel too
AMQP::TcpChannel channel(&connection);
// create a temporary queue
channel.declareQueue("ciao-bella-cpp",AMQP::durable).onSuccess([&connection](const std::string &name, uint32_t messagecount, uint32_t consumercount) {
// report the name of the temporary queue
std::cout << "declared queue " << name << std::endl;
});
// run the loop
uv_run(loop, UV_RUN_DEFAULT);
// done
return 0;
}
@@ -0,0 +1,18 @@
#include "ConnectionHandler.hpp"
#include <iostream>
void ConnectionHandler::onConnected(AMQP::TcpConnection *connection)
{
std::cout << "TCP CONNECTED\n";
}
void ConnectionHandler::onReady(AMQP::TcpConnection *connection)
{
std::cout << "AMQP READY\n";
}
void ConnectionHandler::onError(AMQP::TcpConnection *connection, const char *message)
{
std::cerr << "AMQP error: " << message << std::endl;
}
@@ -0,0 +1,19 @@
#pragma once
#include <uv.h>
#include <amqpcpp.h>
#include <amqpcpp/libuv.h>
class ConnectionHandler : public AMQP::LibUvHandler {
public:
ConnectionHandler(uv_loop_t *loop)
: AMQP::LibUvHandler(loop)
{}
void onConnected(AMQP::TcpConnection *connection) override;
void onReady(AMQP::TcpConnection *connection) override;
void onError(AMQP::TcpConnection *connection, const char *message) override;
~ConnectionHandler() override = default;
};
View File