本文整理汇总了C++中Controller::ErrorText方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::ErrorText方法的具体用法?C++ Controller::ErrorText怎么用?C++ Controller::ErrorText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::ErrorText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoRegister
int DiscoveryClient::DoRegister() const {
Controller cntl;
cntl.http_request().set_method(HTTP_METHOD_POST);
cntl.http_request().uri() = "/discovery/register";
cntl.http_request().set_content_type("application/x-www-form-urlencoded");
butil::IOBufBuilder os;
os << "appid=" << _appid
<< "&hostname=" << _hostname
<< "&addrs=" << _addrs
<< "&env=" << _env
<< "&zone=" << _zone
<< "®ion=" << _region
<< "&status=" << _status
<< "&version=" << _version
<< "&metadata=" << _metadata;
os.move_to(cntl.request_attachment());
s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
if (cntl.Failed()) {
LOG(ERROR) << "Fail to register " << _appid << ": " << cntl.ErrorText();
return -1;
}
std::string error_text;
if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) {
LOG(ERROR) << "Fail to register " << _hostname << " to " << _appid
<< ": " << error_text;
return -1;
}
return 0;
}
示例2: DoCancel
int DiscoveryClient::DoCancel() const {
pthread_once(&s_init_channel_once, InitChannel);
Controller cntl;
cntl.http_request().set_method(HTTP_METHOD_POST);
cntl.http_request().uri() = "/discovery/cancel";
butil::IOBufBuilder os;
os << "appid=" << _appid
<< "&hostname=" << _hostname
<< "&env=" << _env
<< "®ion=" << _region
<< "&zone=" << _zone;
os.move_to(cntl.request_attachment());
s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
if (cntl.Failed()) {
LOG(ERROR) << "Fail to post /discovery/cancel: " << cntl.ErrorText();
return -1;
}
std::string error_text;
if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) {
LOG(ERROR) << "Fail to cancel " << _hostname << " in " << _appid
<< ": " << error_text;
return -1;
}
return 0;
}
示例3: InitChannel
static void InitChannel() {
Channel api_channel;
ChannelOptions channel_options;
channel_options.protocol = PROTOCOL_HTTP;
channel_options.timeout_ms = FLAGS_discovery_timeout_ms;
channel_options.connect_timeout_ms = FLAGS_discovery_timeout_ms / 3;
if (api_channel.Init(FLAGS_discovery_api_addr.c_str(), "", &channel_options) != 0) {
LOG(FATAL) << "Fail to init channel to " << FLAGS_discovery_api_addr;
return;
}
Controller cntl;
cntl.http_request().uri() = FLAGS_discovery_api_addr;
api_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
if (cntl.Failed()) {
LOG(FATAL) << "Fail to access " << cntl.http_request().uri()
<< ": " << cntl.ErrorText();
return;
}
std::string discovery_addr;
if (ParseNodesResult(cntl.response_attachment(), &discovery_addr) != 0) {
LOG(FATAL) << "Fail to parse nodes result from discovery api server";
return;
}
if (s_discovery_channel.Init(discovery_addr.c_str(), "", &channel_options) != 0) {
LOG(FATAL) << "Fail to init channel to " << discovery_addr;
return;
}
}
示例4: Fetchs
int DiscoveryClient::Fetchs(const DiscoveryFetchsParam& req,
std::vector<ServerNode>* servers) const {
if (!req.IsValid()) {
return false;
}
pthread_once(&s_init_channel_once, InitChannel);
servers->clear();
Controller cntl;
cntl.http_request().uri() = butil::string_printf(
"/discovery/fetchs?appid=%s&env=%s&status=%s", req.appid.c_str(),
req.env.c_str(), req.status.c_str());
s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
if (cntl.Failed()) {
LOG(ERROR) << "Fail to get /discovery/fetchs: " << cntl.ErrorText();
return -1;
}
return ParseFetchsResult(cntl.response_attachment(), req.appid.c_str(), servers);
}