当前位置: 首页>>代码示例>>C++>>正文


C++ request::error方法代码示例

本文整理汇总了C++中msgpack::rpc::request::error方法的典型用法代码示例。如果您正苦于以下问题:C++ request::error方法的具体用法?C++ request::error怎么用?C++ request::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msgpack::rpc::request的用法示例。


在下文中一共展示了request::error方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dispatch

void WorkerServer::dispatch(msgpack::rpc::request req)
{
    try
    {
        std::string method;
        req.method().convert(&method);

        WorkerHandlerBase* handler = router_.find(method);
        if (handler)
        {
            //handler->invoke(req);
            worker_pool_.schedule_task(boost::bind(handler_wrapper, handler, req));
        }
        else
        {
            std::cerr << "[WorkerServer] Method not found: " << method << std::endl;
            req.error(msgpack::rpc::NO_METHOD_ERROR);
        }
    }
    catch (const msgpack::type_error& e)
    {
        std::cerr << "[WorkerServer] " << e.what() << std::endl;
        req.error(msgpack::rpc::ARGUMENT_ERROR);
    }
    catch (const std::exception& e)
    {
        std::cerr << "[WorkerServer] " << e.what() << std::endl;
        req.error(std::string(e.what()));
    }
}
开发者ID:RedSunCMX,项目名称:izenelib,代码行数:30,代码来源:WorkerServer.cpp

示例2: handler_wrapper

void handler_wrapper(WorkerHandlerBase* handler, msgpack::rpc::request& req)
{
    try
    {
        handler->invoke(req);
    }
    catch (const msgpack::type_error& e)
    {
        std::cerr << "[WorkerServer] " << e.what() << std::endl;
        req.error(msgpack::rpc::ARGUMENT_ERROR);
    }
    catch (const std::exception& e)
    {
        std::cerr << "[WorkerServer] " << e.what() << std::endl;
        req.error(std::string(e.what()));
    }
}
开发者ID:RedSunCMX,项目名称:izenelib,代码行数:17,代码来源:WorkerServer.cpp

示例3: dispatch

void AdStreamReceiveServer::dispatch(msgpack::rpc::request req)
{
    try
    {
        std::string method;
        req.method().convert(&method);


        if (method == AdStreamReceiveServerRequest::method_names[AdStreamReceiveServerRequest::METHOD_TEST])
        {
            LOG(INFO) << "got heart check msg.";
            //msgpack::type::tuple<bool> params;
            //req.params().convert(&params);
            req.result(true);
        }
        else if (method == AdStreamReceiveServerRequest::method_names[AdStreamReceiveServerRequest::METHOD_PUSH_ADMESSAGE])
        {
            //LOG(INFO) << "got pushed ad msg";
            //LOG(INFO) << "data:" << req.params();

            msgpack::type::tuple<AdMessageListData> params;
            req.params().convert(&params);
            AdMessageListData& data_list = params.get<0>();
            AdStreamSubscriber::get()->onAdMessage(data_list.msg_list);
            req.result(true);
        }
        else
        {
            req.error(msgpack::rpc::NO_METHOD_ERROR);
        }
    }
    catch (const msgpack::type_error& e)
    {
        req.error(msgpack::rpc::ARGUMENT_ERROR);
        LOG(WARNING) << "type error in rpc server." << e.what();
    }
    catch (const std::exception& e)
    {
        req.error(std::string(e.what()));
        LOG(WARNING) << "exception in rpc server." << e.what();
    }
}
开发者ID:Hadoyy,项目名称:sf1r-lite,代码行数:42,代码来源:AdStreamSubscriber.cpp

示例4: dispatch

void server::dispatch(msgpack::rpc::request req)
try {
	std::string method;
	req.method().convert(&method);

	const table_type* table((table_type*)TABLE);

	table_type::const_iterator m = table->find(method);
	if(m == table->end()) {
		req.error(msgpack::rpc::NO_METHOD_ERROR);
		return;
	}

	(*m->second)(this, &req);

} catch (msgpack::type_error& e) {
	req.error(msgpack::rpc::ARGUMENT_ERROR);
	return;

} catch (std::exception& e) {
	req.error(std::string(e.what()));
	return;
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:23,代码来源:ChatServer.cpp

示例5: dispatch

// rpc_server
//   Msgpack-RPC based server with 'hashed' dispatcher.
//   rpc_server can add RPC method on-the-fly.
//
void rpc_server::dispatch(msgpack::rpc::request req) {
  std::string method;
  req.method().convert(&method);

  func_map::iterator fun = funcs_.find(method);
  if (fun == funcs_.end()) {
    req.error(msgpack::rpc::NO_METHOD_ERROR, method);
    return;
  }

  try {
    fun->second->invoke(req);
  } catch(const msgpack::type_error& e) {
    req.error(msgpack::rpc::ARGUMENT_ERROR, std::string(e.what()));
  } catch(const jubatus::core::common::exception::jubatus_exception& e) {
    LOG(WARNING) << "exception in RPC thread: "
                 << e.diagnostic_information(true);
    req.error(std::string(e.what()));
  } catch(const std::exception& e) {
    LOG(ERROR) << "error in RPC thread: "
               << e.what();
    req.error(std::string(e.what()));
  }
}
开发者ID:airtoxin,项目名称:jubatus,代码行数:28,代码来源:rpc_server.cpp

示例6: dispatch

void QContentHubServer::dispatch(msgpack::rpc::request req) {
    try {
        std::string method;
        req.method().convert(&method);

        if(method == "push") {
            msgpack::type::tuple<std::string, std::string> params;
            req.params().convert(&params);
            push_queue(req, params.get<0>(), params.get<1>());
        } else if(method == "pop") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            pop_queue(req, params.get<0>());
        } else if(method == "push_nowait") {
            msgpack::type::tuple<std::string, std::string> params;
            req.params().convert(&params);
            push_queue_nowait(req, params.get<0>(), params.get<1>());
        } else if(method == "pop_nowait") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            pop_queue_nowait(req, params.get<0>());
        } else if(method == "add") {
            msgpack::type::tuple<std::string, int> params;
            req.params().convert(&params);
            add_queue(req, params.get<0>(), params.get<1>());
        /*
        } else if(method == "del") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            del_queue(req, params.get<0>());
        } else if(method == "fdel") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            force_del_queue(req, params.get<0>());
        */
        } else if(method == "set_capacity") {
            msgpack::type::tuple<std::string, int> params;
            req.params().convert(&params);
            set_queue_capacity(req, params.get<0>(), params.get<1>());
        } else if(method == "start") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            start_queue(req, params.get<0>());
        } else if(method == "stop") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            stop_queue(req, params.get<0>());
        } else if(method == "clear") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            clear_queue(req, params.get<0>());
        } else if(method == "stats") {
            stats(req);
        } else if(method == "stat_queue") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            stat_queue(req, params.get<0>());
        } else {
            req.error(msgpack::rpc::NO_METHOD_ERROR);
        }
    } catch (msgpack::type_error& e) {
        req.error(msgpack::rpc::ARGUMENT_ERROR);
        return;

    } catch (std::exception& e) {
        req.error(std::string(e.what()));
        return;
    }
}
开发者ID:liseen,项目名称:qcontenthub,代码行数:69,代码来源:qcontenthub_rpc.cpp

示例7: dispatch

void QUrlQueueServer::dispatch(msgpack::rpc::request req)
{
    try {
        std::string method;
        req.method().convert(&method);

        if(method == "push") {
            msgpack::type::tuple<int, std::string, std::string> params;
            req.params().convert(&params);
            push_url(req, params.get<0>(), params.get<1>(), params.get<2>());
        } else if(method == "pop") {
            pop_url(req);
        } else if(method == "push_url_front") {
            msgpack::type::tuple<int, std::string, std::string> params;
            req.params().convert(&params);
            push_url_front(req, params.get<0>(), params.get<1>(), params.get<2>());
        } else if(method == "start_dump_all") {
            start_dump_all(req);
        } else if(method == "dump_all") {
            dump_all(req);
        } else if(method == "stats") {
            stats(req);
        } else if(method == "set_default_interval") {
            msgpack::type::tuple<int> params;
            req.params().convert(&params);
            set_default_interval(req, params.get<0>());
        } else if(method == "set_site_interval") {
            msgpack::type::tuple<std::string, int> params;
            req.params().convert(&params);
            set_site_interval(req, params.get<0>(), params.get<1>());
        } else if(method == "stat_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            stat_site(req, params.get<0>());
        } else if(method == "dump_ordered_site") {
            msgpack::type::tuple<int> params;
            req.params().convert(&params);
            dump_ordered_site(req, params.get<0>());
        } else if(method == "start_all") {
            start_all(req);
        } else if(method == "stop_all") {
            stop_all(req);
        } else if(method == "start_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            start_site(req, params.get<0>());
        } else if(method == "stop_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            stop_site(req, params.get<0>());
        } else if(method == "clear_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            clear_site(req, params.get<0>());
        } else if(method == "start_dump_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            start_dump_site(req, params.get<0>());
        } else if(method == "dump_site") {
            msgpack::type::tuple<std::string> params;
            req.params().convert(&params);
            dump_site(req, params.get<0>());
        } else if(method == "clear_empty_site") {
            clear_empty_site(req);
        } else {
            req.error(msgpack::rpc::NO_METHOD_ERROR);
        }
    } catch (msgpack::type_error& e) {
        req.error(msgpack::rpc::ARGUMENT_ERROR);
        return;

    } catch (std::exception& e) {
        req.error(std::string(e.what()));
        return;
    }
}
开发者ID:Kayven,项目名称:qcontent,代码行数:76,代码来源:qurlqueue_rpc.cpp


注:本文中的msgpack::rpc::request::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。