rpc server setup
rpc client setup
gflag
头文件
“`
#include <brpc /channel.h>
#include </brpc><brpc /controller.h>
#include </brpc><brpc /reloadable_flags.h>
“`
链接库
target_link_libraries(log spdlog spdk proto_base brpc gflags) # add other lib
声明
DEFINE_int32(online_log_level, 0, "log above this level will be printed");
BRPC_VALIDATE_GFLAG(online_log_level, ::brpc::PassValidate);
引用
DECLARE_int32(online_log_level);
bvar
头文件
#include <bvar/bvar.h>
#include <brpc/channel.h>
#include <brpc/controller.h>
声明
“`
bvar::LatencyRecorder* _total_latency_;
bvar::Adder<uint64_t> g_io_counter;
bvar::Window<bvar::adder <uint64_t> > g_io_recorder("u", "io_frequence", &g_io_counter, 1);
bvar::Adder<uint64_t> g_success_io_counter;
bvar::Window<bvar::adder <uint64_t> > g_success_io_recorder("u", "success_io_frequence", &g_success_io_counter, 1);
<pre><code class=""><br /><br />## 初始化
</code></pre>
<em>total_latency</em> = new bvar::LatencyRecorder("u","total_latency", 60);
<pre><code class=""><br />### 使用
</code></pre>
g_success_io_counter << 1;
<em>io_latency</em>) << (io_done_time_us – io_submit_time_us);
“`