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

Method Init

src/brpc/load_balancer.cpp:82–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82int SharedLoadBalancer::Init(const char* lb_protocol) {
83 std::string lb_name;
84 butil::StringPiece lb_params;
85 if (!ParseParameters(lb_protocol, &lb_name, &lb_params)) {
86 LOG(FATAL) << "Fail to parse this load balancer protocol '" << lb_protocol << '\'';
87 return -1;
88 }
89 const LoadBalancer* lb = LoadBalancerExtension()->Find(lb_name.c_str());
90 if (lb == NULL) {
91 LOG(FATAL) << "Fail to find LoadBalancer by `" << lb_name << "'";
92 return -1;
93 }
94 _lb = lb->New(lb_params);
95 if (_lb == NULL) {
96 LOG(FATAL) << "Fail to new LoadBalancer";
97 return -1;
98 }
99 if (FLAGS_show_lb_in_vars && !_exposed) {
100 ExposeLB();
101 }
102 return 0;
103}
104
105void SharedLoadBalancer::Describe(std::ostream& os,
106 const DescribeOptions& options) {

Callers

nothing calls this directly

Calls 4

LoadBalancerExtensionFunction · 0.85
FindMethod · 0.45
c_strMethod · 0.45
NewMethod · 0.45

Tested by

no test coverage detected