Esempio n. 1
0
message_ptr message::create_request(task_code rpc_code, int timeout_milliseconds, int hash)
{
    message_ptr msg(new message());
    msg->header().local_rpc_code = (uint16_t)rpc_code;
    msg->header().client.hash = hash;
    if (timeout_milliseconds == 0)
    {
        msg->header().client.timeout_ms = task_spec::get(rpc_code)->rpc_timeout_milliseconds;
    }
    else
    {
        msg->header().client.timeout_ms = timeout_milliseconds;
    }    

    strcpy(msg->header().rpc_name, rpc_code.to_string());

    msg->header().id = message::new_id();
    return msg;
}
Esempio n. 2
0
message_ptr message::create_request(task_code rpc_code, int timeout_milliseconds, int hash)
{
    message_ptr msg(new message());
    msg->header().local_rpc_code = (uint16_t)rpc_code;
    msg->header().client.hash = hash;
    if (timeout_milliseconds == 0)
    {
        msg->header().client.timeout_ts_us = ::dsn::service::env::now_us() 
            + static_cast<uint64_t>(task_spec::get(rpc_code)->rpc_timeout_milliseconds) * 1000ULL;
    }
    else
    {
        msg->header().client.timeout_ts_us = ::dsn::service::env::now_us() 
            + static_cast<uint64_t>(timeout_milliseconds) * 1000ULL;
    }    

    const char* rpcName = rpc_code.to_string();
    strcpy(msg->header().rpc_name, rpcName);

    msg->header().id = message::new_id();
    return msg;
}