本文整理汇总了C++中msgpack::rpc::request::method方法的典型用法代码示例。如果您正苦于以下问题:C++ request::method方法的具体用法?C++ request::method怎么用?C++ request::method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack::rpc::request
的用法示例。
在下文中一共展示了request::method方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
}
}
示例2: 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(¶ms);
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(¶ms);
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();
}
}
示例3: 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;
}
示例4: 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()));
}
}
示例5: 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(¶ms);
push_queue(req, params.get<0>(), params.get<1>());
} else if(method == "pop") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
pop_queue(req, params.get<0>());
} else if(method == "push_nowait") {
msgpack::type::tuple<std::string, std::string> params;
req.params().convert(¶ms);
push_queue_nowait(req, params.get<0>(), params.get<1>());
} else if(method == "pop_nowait") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
pop_queue_nowait(req, params.get<0>());
} else if(method == "add") {
msgpack::type::tuple<std::string, int> params;
req.params().convert(¶ms);
add_queue(req, params.get<0>(), params.get<1>());
/*
} else if(method == "del") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
del_queue(req, params.get<0>());
} else if(method == "fdel") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
force_del_queue(req, params.get<0>());
*/
} else if(method == "set_capacity") {
msgpack::type::tuple<std::string, int> params;
req.params().convert(¶ms);
set_queue_capacity(req, params.get<0>(), params.get<1>());
} else if(method == "start") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
start_queue(req, params.get<0>());
} else if(method == "stop") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
stop_queue(req, params.get<0>());
} else if(method == "clear") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
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(¶ms);
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;
}
}
示例6: 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(¶ms);
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(¶ms);
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(¶ms);
set_default_interval(req, params.get<0>());
} else if(method == "set_site_interval") {
msgpack::type::tuple<std::string, int> params;
req.params().convert(¶ms);
set_site_interval(req, params.get<0>(), params.get<1>());
} else if(method == "stat_site") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
stat_site(req, params.get<0>());
} else if(method == "dump_ordered_site") {
msgpack::type::tuple<int> params;
req.params().convert(¶ms);
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(¶ms);
start_site(req, params.get<0>());
} else if(method == "stop_site") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
stop_site(req, params.get<0>());
} else if(method == "clear_site") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
clear_site(req, params.get<0>());
} else if(method == "start_dump_site") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
start_dump_site(req, params.get<0>());
} else if(method == "dump_site") {
msgpack::type::tuple<std::string> params;
req.params().convert(¶ms);
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;
}
}