27 lines
738 B
C++
27 lines
738 B
C++
#pragma once
|
|
|
|
#include "db.hpp"
|
|
#include <atomic>
|
|
#include <condition_variable>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
// Must share the transaction that inserts/updates the job.
|
|
void enqueue_attachment_job(pqxx::work& tx, const std::string& job_id);
|
|
|
|
class OutboxPublisher {
|
|
public:
|
|
OutboxPublisher(std::string db_url, std::string broker_url);
|
|
~OutboxPublisher();
|
|
OutboxPublisher(const OutboxPublisher&) = delete;
|
|
OutboxPublisher& operator=(const OutboxPublisher&) = delete;
|
|
private:
|
|
void run(const std::string& db_url, const std::string& broker_url);
|
|
bool wait_interval();
|
|
std::atomic<bool> stopping_{false};
|
|
std::mutex mutex_;
|
|
std::condition_variable cv_;
|
|
std::thread thread_;
|
|
};
|