Esempio n. 1
0
    App1(cocaine::framework::dispatch_t &d) {
        m_log = d.service_manager()->get_system_logger();
        m_storage = d.service_manager()->get_service<cocaine::framework::storage_service_t>("storage");

        d.on<on_event1>("event1", this);
        d.on("event2", this, &App1::on_event2);

        COCAINE_LOG_WARNING(m_log, "test log");
    }
Esempio n. 2
0
File: app.cpp Progetto: kod3r/grape
queue_app_context::queue_app_context(cocaine::framework::dispatch_t& dispatch)
    : m_id(dispatch.id())
    , m_log(dispatch.service_manager()->get_system_logger())
{
    //FIXME: pass logger explicitly everywhere
    extern void grape_queue_module_set_logger(std::shared_ptr<cocaine::framework::logger_t>);
    grape_queue_module_set_logger(m_log);

    m_queue.reset(new ioremap::grape::queue(m_id));
    m_queue->initialize("queue.conf");
    COCAINE_LOG_INFO(m_log, "%s: queue has been successfully configured", m_id.c_str());

    // register event handlers
    dispatch.on("queue@ping", this, &queue_app_context::process);
    dispatch.on("queue@push", this, &queue_app_context::process);
    dispatch.on("queue@pop-multi", this, &queue_app_context::process);
    dispatch.on("queue@pop-multiple-string", this, &queue_app_context::process);
    dispatch.on("queue@pop", this, &queue_app_context::process);
    dispatch.on("queue@peek", this, &queue_app_context::process);
    dispatch.on("queue@peek-multi", this, &queue_app_context::process);
    dispatch.on("queue@ack", this, &queue_app_context::process);
    dispatch.on("queue@ack-multi", this, &queue_app_context::process);
    dispatch.on("queue@clear", this, &queue_app_context::process);
    dispatch.on("queue@stats-clear", this, &queue_app_context::process);
    dispatch.on("queue@stats", this, &queue_app_context::process);
}