本文整理汇总了C++中message_ptr::reader方法的典型用法代码示例。如果您正苦于以下问题:C++ message_ptr::reader方法的具体用法?C++ message_ptr::reader怎么用?C++ message_ptr::reader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message_ptr
的用法示例。
在下文中一共展示了message_ptr::reader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_remote_cli
void command_manager::on_remote_cli(message_ptr& request)
{
std::string cmd;
unmarshall(request->reader(), cmd);
std::vector<std::string> args;
unmarshall(request->reader(), args);
std::string result;
run_command(cmd, args, result);
auto resp = request->create_response();
marshall(resp->writer(), result);
::dsn::service::rpc::reply(resp);
}
示例2: set_client_request
void mutation::set_client_request(task_code code, message_ptr& request)
{
dassert(client_request == nullptr, "batch is not supported now");
client_request = request;
rpc_code = code;
data.updates.push_back(request->reader().get_remaining_buffer());
}
示例3: update_configuration
void meta_service::update_configuration(message_ptr req, message_ptr resp)
{
if (_state->freezed())
{
meta_response_header rhdr;
rhdr.err = 0;
rhdr.primary_address = primary_address();
configuration_update_request request;
configuration_update_response response;
unmarshall(req, request);
response.err = ERR_STATE_FREEZED;
_state->query_configuration_by_gpid(request.config.gpid, response.config);
marshall(resp, rhdr);
marshall(resp, response);
rpc::reply(resp);
return;
}
auto bb = req->reader().get_remaining_buffer();
uint64_t offset;
int len = bb.length() + sizeof(int32_t);
char* buffer = (char*)malloc(len);
*(int32_t*)buffer = bb.length();
memcpy(buffer + sizeof(int32_t), bb.data(), bb.length());
{
zauto_lock l(_log_lock);
offset = _offset;
_offset += len;
file::write(_log, buffer, len, offset, LPC_CM_LOG_UPDATE, this,
std::bind(&meta_service::on_log_completed, this, std::placeholders::_1, std::placeholders::_2, buffer, req, resp));
}
}
示例4: replica_rw_reply
void replication_app_client_base::replica_rw_reply(
error_code err,
message_ptr& request,
message_ptr& response,
request_context* rc
)
{
if (err != ERR_SUCCESS)
{
goto Retry;
}
int err2;
response->reader().read(err2);
if (err2 != ERR_SUCCESS && err2 != ERR_HANDLER_NOT_FOUND)
{
goto Retry;
}
else
{
error_code err3;
err3.set(err2);
end_request(rc, err3, response);
delete rc;
}
return;
Retry:
// clear partition configuration as it could be wrong
{
zauto_write_lock l(_config_lock);
_config_cache.erase(rc->is_read ? rc->read_header.gpid.pidx : rc->write_header.gpid.pidx);
}
// then retry
call(rc, false);
}
示例5: query_partition_configuration_reply
void replication_app_client_base::query_partition_configuration_reply(error_code err, message_ptr& request, message_ptr& response, int pidx)
{
if (!err)
{
configuration_query_by_index_response resp;
unmarshall(response->reader(), resp);
if (resp.err == ERR_SUCCESS)
{
zauto_write_lock l(_config_lock);
_last_contact_point = response->header().from_address;
if (resp.partitions.size() > 0)
{
if (_app_id != -1 && _app_id != resp.partitions[0].gpid.app_id)
{
dassert(false, "app id is changed (mostly the app was removed and created with the same name), local Vs remote: %u vs %u ",
_app_id, resp.partitions[0].gpid.app_id);
}
_app_id = resp.partitions[0].gpid.app_id;
_app_partition_count = resp.partition_count;
}
for (auto it = resp.partitions.begin(); it != resp.partitions.end(); it++)
{
partition_configuration& new_config = *it;
auto it2 = _config_cache.find(new_config.gpid.pidx);
if (it2 == _config_cache.end())
{
_config_cache[new_config.gpid.pidx] = new_config;
}
else if (it2->second.ballot < new_config.ballot)
{
it2->second = new_config;
}
}
}
}
// send pending client msgs
partition_context* pc = nullptr;
{
zauto_lock l(_requests_lock);
auto it = _pending_requests.find(pidx);
if (it != _pending_requests.end())
{
pc = it->second;
_pending_requests.erase(pidx);
}
}
if (pc != nullptr)
{
for (auto& req : pc->requests)
{
call(req, false);
}
pc->requests.clear();
delete pc;
}
}