-
Notifications
You must be signed in to change notification settings - Fork 59
meta_service & server_state: support set/del/clear envs for app #13
Conversation
3:optional app_env_set_request set_req; | ||
4:optional app_env_del_request del_req; | ||
5:optional app_env_clear_request clear_req; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+struct configuration_update_app_env_request
+{
- 1:string app_name;
- 2:app_env_operation op = app_env_operation.APP_ENV_OP_INVALID;
- 3:optional list keys; // used for set & del
- 4:optional list values; // used for set
- 5:optional string clear_prefix; // used for clear, empty means clear all
+}
include/dsn/cpp/serverlet.h
Outdated
@@ -129,6 +129,12 @@ class serverlet : public virtual clientlet | |||
void (T::*handler)(TRpcHolder), | |||
dsn::gpid gpid = {}); | |||
|
|||
template <typename TRpcHolder> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去掉这个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
master 分支的 rdsn 已经为你提供了这个函数。https://github.com/XiaoMi/rdsn/blob/master/include/dsn/cpp/serverlet.h
@@ -156,6 +156,12 @@ class replication_ddl_client : public clientlet | |||
int32_t backup_history_count_to_keep = 0, | |||
const std::string &start_time = std::string()); | |||
|
|||
dsn::error_code | |||
set_app_env(const std::string &app_name, const std::string &key, const std::string &vlaue); | |||
dsn::error_code del_app_envs(const std::string &app_name, const std::vector<std::string> &keys); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
传std::set更合适吧?
@@ -156,6 +156,12 @@ class replication_ddl_client : public clientlet | |||
int32_t backup_history_count_to_keep = 0, | |||
const std::string &start_time = std::string()); | |||
|
|||
dsn::error_code | |||
set_app_env(const std::string &app_name, const std::string &key, const std::string &vlaue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: value
拼错
void meta_service::update_app_env(const app_env_rpc &env_rpc) | ||
{ | ||
configuration_update_app_env_response response; | ||
RPC_CHECK_STATUS(env_rpc.dsn_request(), response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 env_rpc.response()
,不用构造 response
。
我建议 app_env 相关的代码统一写到一个单独的文件:meta_app_env_service.h/.cpp,方便代码阅读。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还要改
nullptr, | ||
std::bind(&server_state::clear_app_envs, _state.get(), env_rpc)); | ||
break; | ||
default: // app_env_operation::type::APP_ENV_OP_INVALID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果invalid,返回的错误码是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
zauto_read_lock l(_lock); | ||
std::shared_ptr<app_state> app = get_app(app_name); | ||
if (app == nullptr) { | ||
dwarn("del_app_env failed with invalid app_name(%s)", app_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.err是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
zauto_read_lock l(_lock); | ||
std::shared_ptr<app_state> app = get_app(app_name); | ||
if (app == nullptr) { | ||
dwarn("del_app_env failed with invalid app_name(%s)", app_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.err是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
zauto_read_lock l(_lock); | ||
std::shared_ptr<app_state> app = get_app(app_name); | ||
if (app == nullptr) { | ||
dwarn("set_app_env failed with invalid app_name(%s)", app_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.err是什么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
std::cout << "set app env succeed" << std::endl; | ||
if (!response.hint_message.empty()) { | ||
std::cout << "=============================" << std::endl; | ||
std::cout << response.hint_message << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hint_message有没有可能为空?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
操作成功时候为空
2:app_env_operation op = app_env_operation.APP_ENV_OP_INVALID; | ||
3:optional list<string> keys; // used for set and del | ||
4:optional list<string> values; // only used for set | ||
5:optional bool clear_all; // only used for clear; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好去掉clear_all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.