MCPcopy Create free account
hub / github.com/baidu/braft / get

Method get

example/counter/server.cpp:138–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 }
137
138 void get(CounterResponse* response) {
139 // In consideration of consistency. GetRequest to follower should be
140 // rejected.
141 if (!is_leader()) {
142 // This node is a follower or it's not up-to-date. Redirect to
143 // the leader if possible.
144 return redirect(response);
145 }
146
147 // This is the leader and is up-to-date. It's safe to respond client
148 response->set_success(true);
149 response->set_value(_value.load(butil::memory_order_relaxed));
150 }
151
152 bool is_leader() const
153 { return _leader_term.load(butil::memory_order_acquire) > 0; }

Callers 2

senderFunction · 0.45
getMethod · 0.45

Calls 2

is_leaderFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected