koarz commented on code in PR #51708:
URL: https://github.com/apache/doris/pull/51708#discussion_r2166002244
##########
cloud/src/meta-service/meta_service_helper.h:
##########
@@ -226,24 +227,57 @@ inline MetaServiceCode cast_as(TxnErrorCode code) {
}
}
-#define RPC_PREPROCESS(func_name)
\
- StopWatch sw;
\
- auto ctrl = static_cast<brpc::Controller*>(controller);
\
- begin_rpc(#func_name, ctrl, request);
\
- brpc::ClosureGuard closure_guard(done);
\
- [[maybe_unused]] std::stringstream ss;
\
- [[maybe_unused]] MetaServiceCode code = MetaServiceCode::OK;
\
- [[maybe_unused]] std::string msg;
\
- [[maybe_unused]] std::string instance_id;
\
- [[maybe_unused]] bool drop_request = false;
\
- DORIS_CLOUD_DEFER {
\
- response->mutable_status()->set_code(code);
\
- response->mutable_status()->set_msg(msg);
\
- finish_rpc(#func_name, ctrl, response);
\
- closure_guard.reset(nullptr);
\
- if (config::use_detailed_metrics && !instance_id.empty() &&
!drop_request) { \
- g_bvar_ms_##func_name.put(instance_id, sw.elapsed_us());
\
- }
\
+// don't use these macro it just for defer count, reduce useless variable(some
rpc just need one of rw op)
+// If we have to write separate code for each RPC, it would be quite
troublesome
+// After all, adding put, get, and del after the RPC_PREPROCESS macro is
simpler than writing a long string of code
+#define RPCKVCOUNTHELPER(func_name, op) \
Review Comment:
These macros are used to assist with expansion and should not be used under
normal circumstances.
If you don't use them, you'll have to write corresponding code for each RPC.
```cpp
RPC_PREPROCESS(...)
DORIS_CLOUD_DEFER {
rpc_kv..._get_count.put(...);
rpc_kv..._del_count.put(...);
}
```
Now, you only need to add the operations you want to count in RPC_PREPROCESS
`RPC_PREPROCESS(rpc, get, del)`, and it will automatically expand into the code
you need.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]