MCPcopy Create free account
hub / github.com/apache/brpc / Init

Method Init

src/brpc/channel.cpp:250–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250int Channel::Init(const char* server_addr_and_port,
251 const ChannelOptions* options) {
252 GlobalInitializeOrDie();
253 butil::EndPoint point;
254 const AdaptiveProtocolType& ptype = (options ? options->protocol : _options.protocol);
255 const Protocol* protocol = FindProtocol(ptype);
256 if (protocol == NULL || !protocol->support_client()) {
257 LOG(ERROR) << "Channel does not support the protocol";
258 return -1;
259 }
260 if (protocol->parse_server_address != NULL) {
261 if (!protocol->parse_server_address(&point, server_addr_and_port)) {
262 LOG(ERROR) << "Fail to parse address=`" << server_addr_and_port << '\'';
263 return -1;
264 }
265 } else {
266 if (str2endpoint(server_addr_and_port, &point) != 0 &&
267 hostname2endpoint(server_addr_and_port, &point) != 0) {
268 // Many users called the wrong Init(). Print some log to save
269 // our troubleshooting time.
270 if (strstr(server_addr_and_port, "://")) {
271 LOG(ERROR) << "Invalid address=`" << server_addr_and_port
272 << "'. Use Init(naming_service_name, "
273 "load_balancer_name, options) instead.";
274 } else {
275 LOG(ERROR) << "Invalid address=`" << server_addr_and_port << '\'';
276 }
277 return -1;
278 }
279 }
280 return InitSingle(point, server_addr_and_port, options);
281}
282
283int Channel::Init(const char* server_addr, int port,
284 const ChannelOptions* options) {

Callers

nothing calls this directly

Calls 15

GlobalInitializeOrDieFunction · 0.85
FindProtocolFunction · 0.85
str2endpointFunction · 0.85
hostname2endpointFunction · 0.85
ParseURLFunction · 0.85
str2ipFunction · 0.85
hostname2ipFunction · 0.85
ComputeChannelSignatureFunction · 0.85
CreateSocketSSLContextFunction · 0.85
support_clientMethod · 0.80
appendMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected