Example #1
0
    std::shared_ptr<const slot_type::dispatch_type>
    on_enqueue(slot_type::upstream_type&& upstream , const std::string& event, const std::string& id) {
        COCAINE_LOG_DEBUG(log, "processing enqueue '%s' event", event);

        if (auto overseer = this->overseer.lock()) {
            if (id.empty()) {
                return overseer->enqueue(std::move(upstream), event, boost::none);
            } else {
                return overseer->enqueue(std::move(upstream), event, service::node::slave::id_t(id));
            }
        } else {
            upstream.send<
                io::protocol<io::event_traits<io::app::enqueue>::dispatch_type>::scope::error
            >(std::make_error_code(std::errc::broken_pipe), std::string("the application has been stopped"));

            return nullptr;
        }
    }