mq_manager.hpp 1017 Bytes
/*
 * @Author: yangzilong
 * @Date: 2021-12-15 14:52:35
 * @Last Modified by: yangzilong
 * @Email: yangzilong@objecteye.com
 * @Description:
 */

#pragma once

#include "./post_reprocessing.hpp"
#include <map>
#include <memory>

#ifdef POST_USE_RABBITMQ

namespace mq
{
    typedef mq_type_t key_t;
    typedef post_rabbitmq_reprocessing value_t;
    typedef rabbitmq_conn_params_t value_param_t;

    class Manager
    {
        /**
         * @brief is not thread safe.
         *
         */
    public:

        Manager();

        bool add_conn(const key_t &key, const value_param_t& value_param);

        bool del_conn(const key_t &key);

        bool publish(const key_t &key, const char *msg, bool verbose = false);

		/* remove copy construct and copy assignment. */
		Manager(const Manager &) = delete;
		Manager& operator=(const Manager &) = delete;

    private:
        std::map<key_t, std::shared_ptr<value_t>> task_status_to_mq_handle_;

    };
}  // namespace mq

#endif // #ifdef POST_USE_RABBITMQ