worked on the file structure
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.idea/
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
receive ArtworkCreated
|
||||
|
||||
↓
|
||||
|
||||
download original image
|
||||
|
||||
↓
|
||||
reverse search on WWW
|
||||
|
||||
↓
|
||||
|
||||
update database
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user