This is an automated email from the ASF dual-hosted git repository.
serverglen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new cf0aa330 support customized server bvar prefix (#1854)
cf0aa330 is described below
commit cf0aa330f625efd245914c406d37f1cf26c88679
Author: Jenrry You <[email protected]>
AuthorDate: Fri Aug 19 11:42:35 2022 +0800
support customized server bvar prefix (#1854)
---
src/brpc/server.cpp | 6 +++++-
src/brpc/server.h | 4 ++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp
index bc4d4691..8b647fd4 100644
--- a/src/brpc/server.cpp
+++ b/src/brpc/server.cpp
@@ -271,7 +271,11 @@ static bvar::Vector<unsigned, 2>
GetSessionLocalDataCount(void* arg) {
}
std::string Server::ServerPrefix() const {
- return butil::string_printf("%s_%d", g_server_info_prefix,
listen_address().port);
+ if(_options.server_info_name.empty()) {
+ return butil::string_printf("%s_%d", g_server_info_prefix,
listen_address().port);
+ } else {
+ return std::string(g_server_info_prefix) + "_" +
_options.server_info_name;
+ }
}
void* Server::UpdateDerivedVars(void* arg) {
diff --git a/src/brpc/server.h b/src/brpc/server.h
index ef71e810..8c7a3959 100644
--- a/src/brpc/server.h
+++ b/src/brpc/server.h
@@ -241,6 +241,10 @@ struct ServerOptions {
// Default: NULL (disabled)
RedisService* redis_service;
+ // Optional info name for composing server bvar prefix. Read
ServerPrefix() method for details;
+ // Default: ""
+ std::string server_info_name;
+
private:
// SSLOptions is large and not often used, allocate it on heap to
// prevent ServerOptions from being bloated in most cases.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]