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

Method Init

tools/rpc_replay/rpc_replay.cpp:72–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70};
71
72int ChannelGroup::Init() {
73 {
74 // force global initialization of rpc.
75 brpc::Channel dummy_channel;
76 }
77 std::vector<std::pair<brpc::ProtocolType, brpc::Protocol> > protocols;
78 brpc::ListProtocols(&protocols);
79 size_t max_protocol_size = 0;
80 for (size_t i = 0; i < protocols.size(); ++i) {
81 max_protocol_size = std::max(max_protocol_size,
82 (size_t)protocols[i].first);
83 }
84 _chans.resize(max_protocol_size + 1);
85 for (size_t i = 0; i < protocols.size(); ++i) {
86 const brpc::ProtocolType protocol_type = protocols[i].first;
87 const brpc::Protocol protocol = protocols[i].second;
88 brpc::ChannelOptions options;
89 options.protocol = protocol_type;
90 options.connection_type = FLAGS_connection_type;
91 options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
92 options.max_retry = FLAGS_max_retry;
93 if ((options.connection_type == brpc::CONNECTION_TYPE_UNKNOWN ||
94 options.connection_type & protocol.supported_connection_type) &&
95 protocol.support_client() &&
96 protocol.support_server()) {
97 brpc::Channel* chan = new brpc::Channel;
98 if (chan->Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(),
99 &options) != 0) {
100 LOG(ERROR) << "Fail to initialize channel";
101 delete chan;
102 return -1;
103 }
104 _chans[protocol_type] = chan;
105 }
106 }
107 return 0;
108}
109
110ChannelGroup::~ChannelGroup() {
111 for (size_t i = 0; i < _chans.size(); ++i) {

Callers 4

mainFunction · 0.45
access_threadFunction · 0.45
initMethod · 0.45
default_methodMethod · 0.45

Calls 6

ListProtocolsFunction · 0.85
support_clientMethod · 0.80
support_serverMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected