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


C++ Channel::CallMethod方法代码示例

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


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

示例1: 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
        << "&region=" << _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;
}
开发者ID:yzhenma,项目名称:brpc,代码行数:25,代码来源:discovery_naming_service.cpp

示例2: 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
        << "&region=" << _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;
}
开发者ID:yzhenma,项目名称:brpc,代码行数:29,代码来源:discovery_naming_service.cpp

示例3: 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);
}
开发者ID:yzhenma,项目名称:brpc,代码行数:18,代码来源:discovery_naming_service.cpp


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